diff options
author | Araq <rumpf_a@web.de> | 2015-04-10 14:40:53 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2015-04-10 14:40:53 +0200 |
commit | 4d8750ae8c5467002908642888ec38662110a6d1 (patch) | |
tree | e616bafc7b11b63607cedb3c8010c438376ef6c6 /compiler | |
parent | 8ddb58aecc6ddc4c7945258d55debd188c3b5692 (diff) | |
download | Nim-4d8750ae8c5467002908642888ec38662110a6d1.tar.gz |
fixes #2448
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/semfold.nim | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/compiler/semfold.nim b/compiler/semfold.nim index 2e7179673..52931bc2b 100644 --- a/compiler/semfold.nim +++ b/compiler/semfold.nim @@ -170,13 +170,19 @@ proc getIntervalType*(m: TMagic, n: PNode): PType = let a = n.sons[1].typ if isFloatRange(a): # abs(-5.. 1) == (1..5) - result = makeRangeF(a, abs(getFloat(a.n.sons[1])), - abs(getFloat(a.n.sons[0]))) + if a.n[0].floatVal <= 0.0: + result = makeRangeF(a, 0.0, abs(getFloat(a.n.sons[0]))) + else: + result = makeRangeF(a, abs(getFloat(a.n.sons[1])), + abs(getFloat(a.n.sons[0]))) of mAbsI, mAbsI64: let a = n.sons[1].typ if isIntRange(a): - result = makeRange(a, `|abs|`(getInt(a.n.sons[1])), - `|abs|`(getInt(a.n.sons[0]))) + if a.n[0].intVal <= 0: + result = makeRange(a, 0, `|abs|`(getInt(a.n.sons[0]))) + else: + result = makeRange(a, `|abs|`(getInt(a.n.sons[1])), + `|abs|`(getInt(a.n.sons[0]))) of mSucc: let a = n.sons[1].typ let b = n.sons[2].typ |