-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better case coverage error message for alias and range enum (#12913)
- Loading branch information
Showing
6 changed files
with
100 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
discard """ | ||
cmd: "nim check $file" | ||
errormsg: "not all cases are covered; missing: {A, B}" | ||
nimout: ''' | ||
tincompletecaseobject2.nim(16, 1) Error: not all cases are covered; missing: {B, C, D} | ||
tincompletecaseobject2.nim(19, 1) Error: not all cases are covered; missing: {A, C} | ||
tincompletecaseobject2.nim(22, 1) Error: not all cases are covered; missing: {A, B} | ||
''' | ||
""" | ||
type | ||
ABCD = enum A, B, C, D | ||
AliasABCD = ABCD | ||
RangeABC = range[A .. C] | ||
AliasRangeABC = RangeABC | ||
|
||
case AliasABCD A: | ||
of A: discard | ||
|
||
case RangeABC A: | ||
of B: discard | ||
|
||
case AliasRangeABC A: | ||
of C: discard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
discard """ | ||
errormsg: "low(kind) must be 0 for discriminant" | ||
line: 7 | ||
""" | ||
type | ||
HoledObj = object | ||
case kind: int | ||
of 0: a: int | ||
else: discard | ||
|
||
let someInt = low(int) | ||
case someInt | ||
of 938: echo HoledObj(kind: someInt, a: 1) | ||
else: discard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters