This commit is contained in:
Araq 2013-04-23 13:44:38 +02:00
commit 4e6b81e341
2 changed files with 9 additions and 7 deletions

View file

@ -98,13 +98,13 @@ proc ToTreeSet(s: TBitSet, settype: PType, info: TLineInfo): PNode =
result.typ = settype result.typ = settype
result.info = info result.info = info
e = 0 e = 0
while e < high(s) * elemSize: while e < len(s) * elemSize:
if bitSetIn(s, e): if bitSetIn(s, e):
a = e a = e
b = e b = e
while true: while true:
Inc(b) 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) Dec(b)
if a == b: if a == b:
addSon(result, newIntTypeNode(nkIntLit, a + first, elemType)) addSon(result, newIntTypeNode(nkIntLit, a + first, elemType))

View file

@ -1,12 +1,14 @@
discard """ discard """
file: "tbug499771.nim" 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 var sr: TSubRange = 5
echo("TSubRange: " & $sr & " from " & $low(TSubRange) & " to " & echo("TSubRange: " & $sr & " from " & $low(TSubRange) & " to " &
$high(TSubRange)) $high(TSubRange))
const cset = {A} + {B}
echo A in cset, " ", B in cset, " ", C notin cset