diff options
author | Araq <rumpf_a@web.de> | 2013-04-23 13:44:38 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2013-04-23 13:44:38 +0200 |
commit | 4e6b81e34103fe9ea266639d4cf0d554e6382022 (patch) | |
tree | c418a9f31a2a7f3726c4f2dc27f69d51ba29e450 | |
parent | fcb4344ac5996e65b41b82ae472c29eabdda09b5 (diff) | |
download | Nim-4e6b81e34103fe9ea266639d4cf0d554e6382022.tar.gz |
fixes #395
-rw-r--r-- | compiler/nimsets.nim | 4 | ||||
-rw-r--r-- | tests/run/tbug499771.nim | 12 |
2 files changed, 9 insertions, 7 deletions
diff --git a/compiler/nimsets.nim b/compiler/nimsets.nim index 118046283..93bccae24 100644 --- a/compiler/nimsets.nim +++ b/compiler/nimsets.nim @@ -98,13 +98,13 @@ proc ToTreeSet(s: TBitSet, settype: PType, info: TLineInfo): PNode = result.typ = settype result.info = info e = 0 - while e < high(s) * elemSize: + while e < len(s) * elemSize: if bitSetIn(s, e): a = e b = e while true: Inc(b) - if (b > high(s) * elemSize) or not bitSetIn(s, b): break + if (b >= len(s) * elemSize) or not bitSetIn(s, b): break Dec(b) if a == b: addSon(result, newIntTypeNode(nkIntLit, a + first, elemType)) diff --git a/tests/run/tbug499771.nim b/tests/run/tbug499771.nim index 633ab39f6..682148422 100644 --- a/tests/run/tbug499771.nim +++ b/tests/run/tbug499771.nim @@ -1,12 +1,14 @@ discard """ file: "tbug499771.nim" - output: "TSubRange: 5 from 1 to 10" + output: '''TSubRange: 5 from 1 to 10 +true true true''' """ -type TSubRange = range[1 .. 10] +type + TSubRange = range[1 .. 10] + TEnum = enum A, B, C var sr: TSubRange = 5 echo("TSubRange: " & $sr & " from " & $low(TSubRange) & " to " & $high(TSubRange)) - - - +const cset = {A} + {B} +echo A in cset, " ", B in cset, " ", C notin cset |