diff options
Diffstat (limited to 'compiler/semstmts.nim')
-rw-r--r-- | compiler/semstmts.nim | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 6423b8fb3..5d1990e33 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -878,10 +878,14 @@ proc semCase(c: PContext, n: PNode; flags: TExprFlags): PNode = var covered: BiggestInt = 0 var typ = commonTypeBegin var hasElse = false - let caseTyp = skipTypes(n.sons[0].typ, abstractVarRange-{tyTypeDesc}) + let caseTyp = skipTypes(n.sons[0].typ, abstractVar-{tyTypeDesc}) + const shouldChckCovered = {tyInt..tyInt64, tyChar, tyEnum, tyUInt..tyUInt32, tyBool} case caseTyp.kind - of tyInt..tyInt64, tyChar, tyEnum, tyUInt..tyUInt32, tyBool: + of shouldChckCovered: chckCovered = true + of tyRange: + if skipTypes(caseTyp.sons[0], abstractInst).kind in shouldChckCovered: + chckCovered = true of tyFloat..tyFloat128, tyString, tyError: discard else: @@ -889,7 +893,7 @@ proc semCase(c: PContext, n: PNode; flags: TExprFlags): PNode = result = handleCaseStmtMacro(c, n) if result != nil: return result - localError(c.config, n.info, errSelectorMustBeOfCertainTypes) + localError(c.config, n.sons[0].info, errSelectorMustBeOfCertainTypes) return for i in 1 ..< sonsLen(n): var x = n.sons[i] |