mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 05:50:30 +00:00
@@ -1587,20 +1587,24 @@ proc genInOp(p: BProc, e: PNode, d: var TLoc) =
|
||||
e.sons[2]
|
||||
initLocExpr(p, ea, a)
|
||||
initLoc(b, locExpr, e, OnUnknown)
|
||||
b.r = rope("(")
|
||||
var length = sonsLen(e.sons[1])
|
||||
for i in countup(0, length - 1):
|
||||
let it = e.sons[1].sons[i]
|
||||
if it.kind == nkRange:
|
||||
initLocExpr(p, it.sons[0], x)
|
||||
initLocExpr(p, it.sons[1], y)
|
||||
addf(b.r, "$1 >= $2 && $1 <= $3",
|
||||
[rdCharLoc(a), rdCharLoc(x), rdCharLoc(y)])
|
||||
else:
|
||||
initLocExpr(p, it, x)
|
||||
addf(b.r, "$1 == $2", [rdCharLoc(a), rdCharLoc(x)])
|
||||
if i < length - 1: add(b.r, " || ")
|
||||
add(b.r, ")")
|
||||
if length > 0:
|
||||
b.r = rope("(")
|
||||
for i in countup(0, length - 1):
|
||||
let it = e.sons[1].sons[i]
|
||||
if it.kind == nkRange:
|
||||
initLocExpr(p, it.sons[0], x)
|
||||
initLocExpr(p, it.sons[1], y)
|
||||
addf(b.r, "$1 >= $2 && $1 <= $3",
|
||||
[rdCharLoc(a), rdCharLoc(x), rdCharLoc(y)])
|
||||
else:
|
||||
initLocExpr(p, it, x)
|
||||
addf(b.r, "$1 == $2", [rdCharLoc(a), rdCharLoc(x)])
|
||||
if i < length - 1: add(b.r, " || ")
|
||||
add(b.r, ")")
|
||||
else:
|
||||
# handle the case of an empty set
|
||||
b.r = rope("0")
|
||||
putIntoDest(p, d, e, b.r)
|
||||
else:
|
||||
assert(e.sons[1].typ != nil)
|
||||
|
||||
7
tests/iter/t8041.nim
Normal file
7
tests/iter/t8041.nim
Normal file
@@ -0,0 +1,7 @@
|
||||
iterator xy[T](a: T, b: set[T]): T =
|
||||
if a in b:
|
||||
yield a
|
||||
|
||||
for a in xy(1'i8, {}):
|
||||
for b in xy(a, {}):
|
||||
echo a
|
||||
Reference in New Issue
Block a user