diff options
author | Araq <rumpf_a@web.de> | 2015-04-28 15:01:05 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2015-04-28 15:01:05 +0200 |
commit | 3fa2e79814f3b093fc90e958cb805dbc1cf837be (patch) | |
tree | 7bfd064097777802caf9a814944249719099ce59 | |
parent | c6398d408de89672d1df21ee84507978f2320ba8 (diff) | |
download | Nim-3fa2e79814f3b093fc90e958cb805dbc1cf837be.tar.gz |
sempass2: bugfixes
-rw-r--r-- | compiler/guards.nim | 4 | ||||
-rw-r--r-- | compiler/sempass2.nim | 12 |
2 files changed, 7 insertions, 9 deletions
diff --git a/compiler/guards.nim b/compiler/guards.nim index dc2b24add..df2c1dd75 100644 --- a/compiler/guards.nim +++ b/compiler/guards.nim @@ -123,7 +123,7 @@ proc neg(n: PNode): PNode = let eAsNode = newIntNode(nkIntLit, e.sym.position) if not inSet(n.sons[1], eAsNode): s.add eAsNode 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]) else: # 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) = for i in 1..n.len-1: 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 diff --git a/compiler/sempass2.nim b/compiler/sempass2.nim index 6bc0fa32c..adf03be64 100644 --- a/compiler/sempass2.nim +++ b/compiler/sempass2.nim @@ -560,7 +560,10 @@ proc trackCase(tracked: PEffects, n: PNode) = track(tracked, n.sons[0]) let oldState = tracked.init.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 toCover = 0 for i in 1.. <n.len: @@ -575,13 +578,8 @@ proc trackCase(tracked: PEffects, n: PNode) = for i in oldState.. <tracked.init.len: 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) - if exh: + if not stringCase or lastSon(n).kind == nkElse: for id, count in items(inter): if count >= toCover: tracked.init.add id # else we can't merge |