parent
7ae52d7791
commit
73841ae194
2 changed files with 57 additions and 4 deletions
|
|
@ -738,7 +738,7 @@ proc transformFor(c: PTransf, n: PNode): PNode =
|
||||||
pushInfoContext(c.graph.config, n.info)
|
pushInfoContext(c.graph.config, n.info)
|
||||||
inc(c.inlining)
|
inc(c.inlining)
|
||||||
stmtList.add(transform(c, body))
|
stmtList.add(transform(c, body))
|
||||||
#findWrongOwners(c, stmtList.pnode)
|
#findWrongOwners(c, stmtList.PNode)
|
||||||
dec(c.inlining)
|
dec(c.inlining)
|
||||||
popInfoContext(c.graph.config)
|
popInfoContext(c.graph.config)
|
||||||
popTransCon(c)
|
popTransCon(c)
|
||||||
|
|
@ -1019,10 +1019,11 @@ proc transform(c: PTransf, n: PNode): PNode =
|
||||||
of nkAsgn:
|
of nkAsgn:
|
||||||
result = transformAsgn(c, n)
|
result = transformAsgn(c, n)
|
||||||
of nkIdentDefs, nkConstDef:
|
of nkIdentDefs, nkConstDef:
|
||||||
result = n
|
result = newTransNode(n)
|
||||||
result[0] = transform(c, n[0])
|
result[0] = transform(c, n[0])
|
||||||
# Skip the second son since it only contains an unsemanticized copy of the
|
# Skip the second son since it only contains an unsemanticized copy of the
|
||||||
# variable type used by docgen
|
# variable type used by docgen
|
||||||
|
result[1] = n[1]
|
||||||
result[2] = transform(c, n[2])
|
result[2] = transform(c, n[2])
|
||||||
# XXX comment handling really sucks:
|
# XXX comment handling really sucks:
|
||||||
if importantComments(c.graph.config):
|
if importantComments(c.graph.config):
|
||||||
|
|
@ -1033,8 +1034,10 @@ proc transform(c: PTransf, n: PNode): PNode =
|
||||||
# (bug #2604). We need to patch this environment here too:
|
# (bug #2604). We need to patch this environment here too:
|
||||||
let a = n[1]
|
let a = n[1]
|
||||||
if a.kind == nkSym:
|
if a.kind == nkSym:
|
||||||
n[1] = transformSymAux(c, a)
|
result = copyTree(n)
|
||||||
return n
|
result[1] = transformSymAux(c, a)
|
||||||
|
else:
|
||||||
|
result = n
|
||||||
of nkExceptBranch:
|
of nkExceptBranch:
|
||||||
result = transformExceptBranch(c, n)
|
result = transformExceptBranch(c, n)
|
||||||
of nkCheckedFieldExpr:
|
of nkCheckedFieldExpr:
|
||||||
|
|
|
||||||
|
|
@ -62,3 +62,53 @@ type Rule[T] = (int, T)
|
||||||
var t: seq[Rule[int]]
|
var t: seq[Rule[int]]
|
||||||
for (c, t) in t:
|
for (c, t) in t:
|
||||||
discard
|
discard
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import std/sugar
|
||||||
|
|
||||||
|
# bug #14165
|
||||||
|
iterator log_nodups_hamming(): int {.inline.} =
|
||||||
|
let lb3 = 1
|
||||||
|
let lb4 = 123
|
||||||
|
proc mul3(): int = lb3 + lb4
|
||||||
|
yield mul3()
|
||||||
|
|
||||||
|
for h in log_nodups_hamming():
|
||||||
|
break
|
||||||
|
for h in log_nodups_hamming():
|
||||||
|
break
|
||||||
|
for h in log_nodups_hamming():
|
||||||
|
break
|
||||||
|
|
||||||
|
# bug #18536
|
||||||
|
iterator envPairs*(): int =
|
||||||
|
var foo: seq[int]
|
||||||
|
proc fun() =
|
||||||
|
foo = @[]
|
||||||
|
fun()
|
||||||
|
yield 3
|
||||||
|
|
||||||
|
proc main() =
|
||||||
|
for a in envPairs():
|
||||||
|
discard
|
||||||
|
for a in envPairs():
|
||||||
|
discard
|
||||||
|
static: main()
|
||||||
|
main()
|
||||||
|
|
||||||
|
# bug #6269
|
||||||
|
iterator makeFn(outer_val: int): proc(a: int): int =
|
||||||
|
for i in 0..1:
|
||||||
|
yield proc(a:int): int =
|
||||||
|
return a + i.int
|
||||||
|
|
||||||
|
let v1 = 42
|
||||||
|
|
||||||
|
let res = collect:
|
||||||
|
for fn1 in makeFn(v1):
|
||||||
|
let v2 = fn1(v1)
|
||||||
|
for fn2 in makeFn(v2):
|
||||||
|
fn2(v2)
|
||||||
|
|
||||||
|
doAssert res == @[42, 43, 43, 44]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue