sempass2: bugfixes
This commit is contained in:
parent
c6398d408d
commit
3fa2e79814
2 changed files with 7 additions and 9 deletions
|
|
@ -123,7 +123,7 @@ proc neg(n: PNode): PNode =
|
||||||
let eAsNode = newIntNode(nkIntLit, e.sym.position)
|
let eAsNode = newIntNode(nkIntLit, e.sym.position)
|
||||||
if not inSet(n.sons[1], eAsNode): s.add eAsNode
|
if not inSet(n.sons[1], eAsNode): s.add eAsNode
|
||||||
result.sons[1] = s
|
result.sons[1] = s
|
||||||
elif lengthOrd(t) < 1000:
|
elif t.kind notin {tyString, tySequence} and lengthOrd(t) < 1000:
|
||||||
result.sons[1] = complement(n.sons[1])
|
result.sons[1] = complement(n.sons[1])
|
||||||
else:
|
else:
|
||||||
# not ({2, 3, 4}.contains(x)) x != 2 and x != 3 and x != 4
|
# not ({2, 3, 4}.contains(x)) x != 2 and x != 3 and x != 4
|
||||||
|
|
@ -908,5 +908,5 @@ proc buildProperFieldCheck(access, check: PNode): PNode =
|
||||||
proc checkFieldAccess*(m: TModel, n: PNode) =
|
proc checkFieldAccess*(m: TModel, n: PNode) =
|
||||||
for i in 1..n.len-1:
|
for i in 1..n.len-1:
|
||||||
let check = buildProperFieldCheck(n.sons[0], n.sons[i])
|
let check = buildProperFieldCheck(n.sons[0], n.sons[i])
|
||||||
if m.doesImply(check) != impYes:
|
if check != nil and m.doesImply(check) != impYes:
|
||||||
message(n.info, warnProveField, renderTree(n.sons[0])); break
|
message(n.info, warnProveField, renderTree(n.sons[0])); break
|
||||||
|
|
|
||||||
|
|
@ -560,7 +560,10 @@ proc trackCase(tracked: PEffects, n: PNode) =
|
||||||
track(tracked, n.sons[0])
|
track(tracked, n.sons[0])
|
||||||
let oldState = tracked.init.len
|
let oldState = tracked.init.len
|
||||||
let oldFacts = tracked.guards.len
|
let oldFacts = tracked.guards.len
|
||||||
let interesting = interestingCaseExpr(n.sons[0]) and warnProveField in gNotes
|
let stringCase = skipTypes(n.sons[0].typ,
|
||||||
|
abstractVarRange-{tyTypeDesc}).kind in {tyFloat..tyFloat128, tyString}
|
||||||
|
let interesting = not stringCase and interestingCaseExpr(n.sons[0]) and
|
||||||
|
warnProveField in gNotes
|
||||||
var inter: TIntersection = @[]
|
var inter: TIntersection = @[]
|
||||||
var toCover = 0
|
var toCover = 0
|
||||||
for i in 1.. <n.len:
|
for i in 1.. <n.len:
|
||||||
|
|
@ -575,13 +578,8 @@ proc trackCase(tracked: PEffects, n: PNode) =
|
||||||
for i in oldState.. <tracked.init.len:
|
for i in oldState.. <tracked.init.len:
|
||||||
addToIntersection(inter, tracked.init[i])
|
addToIntersection(inter, tracked.init[i])
|
||||||
|
|
||||||
let exh = case skipTypes(n.sons[0].typ, abstractVarRange-{tyTypeDesc}).kind
|
|
||||||
of tyFloat..tyFloat128, tyString:
|
|
||||||
lastSon(n).kind == nkElse
|
|
||||||
else:
|
|
||||||
true
|
|
||||||
setLen(tracked.init, oldState)
|
setLen(tracked.init, oldState)
|
||||||
if exh:
|
if not stringCase or lastSon(n).kind == nkElse:
|
||||||
for id, count in items(inter):
|
for id, count in items(inter):
|
||||||
if count >= toCover: tracked.init.add id
|
if count >= toCover: tracked.init.add id
|
||||||
# else we can't merge
|
# else we can't merge
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue