nim-works/nimskull

Misleading error for case statement when range expression in of-branch is invalid

Open

#1,511 opened on Apr 11, 2025

 (0 comments) (0 reactions) (0 assignees)Nim (39 forks)auto 404
bugcompiler/msgsgood first issue

Repository metrics

Stars
 (346 stars)
PR merge metrics
 (PR metrics pending)

Description

Example

type
  E {.pure.} = enum A, B, C, D
  A = int

var e: E
case e
of A..C: discard
of D: discard

Actual Output

test.nim(6, 1) Error: not all cases are covered; missing: {A, B, C}

Expected Output

test.nim(7, 4) Error: type mismatch: got 'typedesc[A]' for 'A' but expected 'E = enum'

Possible Solution

  • This is likely just an error propagation issue for infix, because the real error can be found if --errorMax:0 is used.

Contributor guide