Skip to content

Commit

Permalink
fixes #11523
Browse files Browse the repository at this point in the history
(cherry picked from commit 135fdde)
  • Loading branch information
Araq authored and narimiran committed Jul 2, 2019
1 parent d206e88 commit 843ae00
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion compiler/lambdalifting.nim
Expand Up @@ -758,7 +758,8 @@ proc liftCapturedVars(n: PNode; owner: PSym; d: DetectionPass;
# transform, let's not touch the LHS in order to make the lifting pass
# correct when `result` is lifted
n[0].sons[1] = liftCapturedVars(n[0].sons[1], owner, d, c)
else: assert n[0].kind == nkEmpty
else:
n.sons[0] = liftCapturedVars(n[0], owner, d, c)
else:
if owner.isIterator:
if nfLL in n.flags:
Expand Down
11 changes: 10 additions & 1 deletion tests/closure/tclosure_issues.nim
@@ -1,5 +1,6 @@
discard """
output: '''true'''
output: '''true
(999, 0)'''
"""


Expand Down Expand Up @@ -52,3 +53,11 @@ block tissue1911:
proc baz() : int = helper()

return (bar, baz)

# bug #11523
proc foo(): proc =
let a = 999
return proc(): (int, int) =
return (a, 0)

echo foo()()

0 comments on commit 843ae00

Please sign in to comment.