mirror of
https://github.com/nim-lang/Nim.git
synced 2026-08-04 14:38:38 +00:00
Nested transformBody/liftLambdas passes used a fresh DetectionPass, so getEnvTypeForOwner could allocate a duplicate PType for the same owner while :envP already referenced the inner pass type. When addClosureParam saw cp.typ != t, it errored. If both types are env objects for the same routine owner, reuse cp.typ and sync ownerToType. Adds regression test tests/iter/t21242_nested_closure_in_iter.nim.
24 lines
340 B
Nim
24 lines
340 B
Nim
# Regression test for bug #21242
|
|
discard """
|
|
action: compile
|
|
"""
|
|
|
|
iterator iterSome(): int =
|
|
proc inner1() =
|
|
let something = 6
|
|
proc inner2() =
|
|
let othersomething = something
|
|
inner2()
|
|
|
|
for n in 0 .. 10:
|
|
inner1()
|
|
yield n
|
|
|
|
proc test() =
|
|
proc test1() =
|
|
for v in iterSome():
|
|
discard
|
|
test1()
|
|
|
|
test()
|