Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nim check (or --errormax:N) reports redundant errors #16178

Open
timotheecour opened this issue Nov 29, 2020 · 0 comments
Open

nim check (or --errormax:N) reports redundant errors #16178

timotheecour opened this issue Nov 29, 2020 · 0 comments

Comments

@timotheecour
Copy link
Member

timotheecour commented Nov 29, 2020

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

Some gagging already occurs in some cases but it seems more by accident than by design, eg see #16001 (comment)

Additional Information

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant