Skip to content

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

@timotheecour

Description

@timotheecour

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions