mirror of
https://github.com/nim-lang/Nim.git
synced 2026-05-28 15:55:14 +00:00
fixes #25591; error with capture in closure iterator
This commit is contained in:
@@ -520,6 +520,8 @@ proc detectCapturedVars(n: PNode; owner: PSym; c: var DetectionPass) =
|
||||
of nkLambdaKinds, nkIteratorDef:
|
||||
if n.typ != nil:
|
||||
detectCapturedVars(n[namePos], owner, c)
|
||||
of nkClosure:
|
||||
detectCapturedVars(n[1], owner, c)
|
||||
of nkReturnStmt:
|
||||
detectCapturedVars(n[0], owner, c)
|
||||
of nkIdentDefs:
|
||||
|
||||
@@ -239,6 +239,17 @@ block t2023_objiter:
|
||||
var o = init()
|
||||
echo(o.iter())
|
||||
|
||||
block: # bug #25591
|
||||
iterator h(): int =
|
||||
let n = 0
|
||||
(proc() = discard n)()
|
||||
yield 0
|
||||
|
||||
proc a() =
|
||||
iterator m(): int {.closure.} = (for _ in h(): discard)
|
||||
let _ = m
|
||||
|
||||
a()
|
||||
|
||||
block:
|
||||
# bug #13739
|
||||
|
||||
Reference in New Issue
Block a user