mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-26 09:14:00 +00:00
fixes #4070
This commit is contained in:
@@ -716,6 +716,7 @@ proc liftCapturedVars(n: PNode; owner: PSym; d: DetectionPass;
|
||||
#localError(n.info, "internal error: closure to closure created")
|
||||
# now we know better, so patch it:
|
||||
n.sons[0] = x.sons[0]
|
||||
n.sons[1] = x.sons[1]
|
||||
of nkLambdaKinds, nkIteratorDef:
|
||||
if n.typ != nil and n[namePos].kind == nkSym:
|
||||
let m = newSymNode(n[namePos].sym)
|
||||
|
||||
20
tests/closure/tdeeplynested.nim
Normal file
20
tests/closure/tdeeplynested.nim
Normal file
@@ -0,0 +1,20 @@
|
||||
discard """
|
||||
output: '''108'''
|
||||
"""
|
||||
|
||||
# bug #4070
|
||||
|
||||
proc id(f: (proc())): auto =
|
||||
return f
|
||||
|
||||
proc foo(myinteger: int): (iterator(): int) =
|
||||
return iterator(): int {.closure.} =
|
||||
proc bar() =
|
||||
proc kk() =
|
||||
echo "int: ", myinteger
|
||||
|
||||
kk()
|
||||
|
||||
id(bar)()
|
||||
|
||||
discard foo(108)()
|
||||
Reference in New Issue
Block a user