bugfix: case exhaustiveness checking
This commit is contained in:
parent
b7d1901747
commit
02b1503e1f
5 changed files with 27 additions and 6 deletions
|
|
@ -156,6 +156,10 @@ proc skipConv*(n: PNode): PNode =
|
|||
result = n.sons[1]
|
||||
else: result = n
|
||||
|
||||
proc skipConvTakeType*(n: PNode): PNode =
|
||||
result = n.skipConv
|
||||
result.typ = n.typ
|
||||
|
||||
proc SameValue*(a, b: PNode): bool =
|
||||
result = false
|
||||
case a.kind
|
||||
|
|
|
|||
|
|
@ -44,9 +44,9 @@ proc inSet(s: PNode, elem: PNode): bool =
|
|||
return true
|
||||
result = false
|
||||
|
||||
proc overlap(a, b: PNode): bool =
|
||||
if a.kind == nkRange:
|
||||
if b.kind == nkRange:
|
||||
proc overlap(a, b: PNode): bool =
|
||||
if a.kind == nkRange:
|
||||
if b.kind == nkRange:
|
||||
# X..Y and C..D overlap iff (X <= D and C <= Y)
|
||||
result = leValue(a.sons[0], b.sons[1]) and
|
||||
leValue(b.sons[0], a.sons[1])
|
||||
|
|
|
|||
|
|
@ -323,8 +323,8 @@ proc semBranchRange(c: PContext, t, a, b: PNode, covered: var biggestInt): PNode
|
|||
checkMinSonsLen(t, 1)
|
||||
let ac = semConstExpr(c, a)
|
||||
let bc = semConstExpr(c, b)
|
||||
let at = fitNode(c, t.sons[0].typ, ac)
|
||||
let bt = fitNode(c, t.sons[0].typ, bc)
|
||||
let at = fitNode(c, t.sons[0].typ, ac).skipConvTakeType
|
||||
let bt = fitNode(c, t.sons[0].typ, bc).skipConvTakeType
|
||||
|
||||
result = newNodeI(nkRange, a.info)
|
||||
result.add(at)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue