Files
Nim/tests/iter/t21242_nested_closure_in_iter.nim
dxxb 0028ea563c Fix inconsistent env type with nested procs in iterators (#21242) (#25699)
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.
2026-04-04 19:47:01 +02:00

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()