de-deprecate silly warning about non-exhaustive string case statments
This commit is contained in:
parent
57b7c45128
commit
e8cfa14354
1 changed files with 3 additions and 7 deletions
|
|
@ -205,13 +205,12 @@ proc semCase(c: PContext, n: PNode): PNode =
|
||||||
var covered: BiggestInt = 0
|
var covered: BiggestInt = 0
|
||||||
var typ = commonTypeBegin
|
var typ = commonTypeBegin
|
||||||
var hasElse = false
|
var hasElse = false
|
||||||
var notOrdinal = false
|
|
||||||
let caseTyp = skipTypes(n.sons[0].typ, abstractVarRange-{tyTypeDesc})
|
let caseTyp = skipTypes(n.sons[0].typ, abstractVarRange-{tyTypeDesc})
|
||||||
case caseTyp.kind
|
case caseTyp.kind
|
||||||
of tyInt..tyInt64, tyChar, tyEnum, tyUInt..tyUInt32, tyBool:
|
of tyInt..tyInt64, tyChar, tyEnum, tyUInt..tyUInt32, tyBool:
|
||||||
chckCovered = true
|
chckCovered = true
|
||||||
of tyFloat..tyFloat128, tyString, tyError:
|
of tyFloat..tyFloat128, tyString, tyError:
|
||||||
notOrdinal = true
|
discard
|
||||||
else:
|
else:
|
||||||
localError(n.info, errSelectorMustBeOfCertainTypes)
|
localError(n.info, errSelectorMustBeOfCertainTypes)
|
||||||
return
|
return
|
||||||
|
|
@ -244,9 +243,6 @@ proc semCase(c: PContext, n: PNode): PNode =
|
||||||
hasElse = true
|
hasElse = true
|
||||||
else:
|
else:
|
||||||
illFormedAst(x)
|
illFormedAst(x)
|
||||||
if notOrdinal and not hasElse:
|
|
||||||
message(n.info, warnDeprecated,
|
|
||||||
"use 'else: discard'; non-ordinal case without 'else'")
|
|
||||||
if chckCovered:
|
if chckCovered:
|
||||||
if covered == toCover(n.sons[0].typ):
|
if covered == toCover(n.sons[0].typ):
|
||||||
hasElse = true
|
hasElse = true
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue