-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Labels
Description
This is meant as a more actional issue than #16001.
nim check (or --errormax:N) reports redundant errors
Example 1
when true:
type E = enum A, B, C
var x = A
var t1 = case x:
of A: "a"
of B: "b"
# of C: "c"Current Output
nim r --errormax:10 --listfullpaths:off t11383.nim
t11383.nim(57, 12) Error: not all cases are covered; missing: {C}
t11383.nim(58, 11) Error: expression '"a"' is of type 'string' and has to be used (or discarded)
t11383.nim(59, 11) Error: expression '"b"' is of type 'string' and has to be used (or discarded)
t11383.nim(57, 12) Error: expression 'case x
of A:
"a"
of B:
"b"' has no type (or is ambiguous)
Expected Output
only 1st error message is shown, the other ones are consequence of it and should be gagged
t11383.nim(57, 12) Error: not all cases are covered; missing: {C}
Example 2: found 'bad5' [unknown declared in should not be reported
block:
let a = bad5(1)as of 01bca8c:
XDG_CONFIG_HOME= nim check --hints:off --spellsuggest:0 $timn_D/tests/nim/all/t12213.nim
/Users/timothee/git_clone/nim/timn/tests/nim/all/t12213.nim(6, 11) Error: undeclared identifier: 'bad5'
/Users/timothee/git_clone/nim/timn/tests/nim/all/t12213.nim(6, 15) Error: attempting to call routine: 'bad5'
found 'bad5' [unknown declared in /Users/timothee/git_clone/nim/timn/tests/nim/all/t12213.nim(6, 11)]
/Users/timothee/git_clone/nim/timn/tests/nim/all/t12213.nim(6, 15) Error: attempting to call routine: 'bad5'
found 'bad5' [unknown declared in /Users/timothee/git_clone/nim/timn/tests/nim/all/t12213.nim(6, 11)]
/Users/timothee/git_clone/nim/timn/tests/nim/all/t12213.nim(6, 15) Error: expression 'bad5' cannot be called
/Users/timothee/git_clone/nim/timn/tests/nim/all/t12213.nim(6, 15) Error: expression '' has no type (or is ambiguous)
/Users/timothee/git_clone/nim/timn/tests/nim/all/t12213.nim(6, 7) Error: 'let' symbol requires an initialization
Example 3: redundant errors on undeclared routine call
the only thing that should be reported here is Error: undeclared identifier: 'bad5'
block:
let a = bad5(1)as of 01bca8c:
/Users/timothee/git_clone/nim/timn/tests/nim/all/t12213.nim(6, 11) Error: undeclared identifier: 'bad5'
/Users/timothee/git_clone/nim/timn/tests/nim/all/t12213.nim(6, 15) Error: attempting to call routine: 'bad5'
found 'bad5' [unknown declared in /Users/timothee/git_clone/nim/timn/tests/nim/all/t12213.nim(6, 11)]
/Users/timothee/git_clone/nim/timn/tests/nim/all/t12213.nim(6, 15) Error: attempting to call routine: 'bad5'
found 'bad5' [unknown declared in /Users/timothee/git_clone/nim/timn/tests/nim/all/t12213.nim(6, 11)]
/Users/timothee/git_clone/nim/timn/tests/nim/all/t12213.nim(6, 15) Error: expression 'bad5' cannot be called
/Users/timothee/git_clone/nim/timn/tests/nim/all/t12213.nim(6, 15) Error: expression '' has no type (or is ambiguous)
/Users/timothee/git_clone/nim/timn/tests/nim/all/t12213.nim(6, 7) Error: 'let' symbol requires an initialization
Possible Solution
- introduce
nkError(but see Nimsuggest misleads, but newcomers use it by default #16001 (comment)) or some other name, eg:nkPoison(nkNone already is used in nim repo and would be confusing) to gag redundant errors and preventing them bubbling up, as described in , as described in Nimsuggest misleads, but newcomers use it by default #16001 (comment) and https://forum.dlang.org/thread/k0bb3t$ad4$1@digitalmars.com?page=2
Some gagging already occurs in some cases but it seems more by accident than by design, eg see #16001 (comment)
Additional Information
- refs Nimsuggest misleads, but newcomers use it by default #16001 (comment)
- devel 1.5.1 d29eddf
- EDIT: maybe a duplicate of Duplicated messages for nim check #4183? but this issue may have more info; at least both should be consolidated