summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/lambdalifting.nim3
-rw-r--r--tests/closure/tclosure_issues.nim11
2 files changed, 12 insertions, 2 deletions
diff --git a/compiler/lambdalifting.nim b/compiler/lambdalifting.nim
index 1d542d7f5..29d6f122e 100644
--- a/compiler/lambdalifting.nim
+++ b/compiler/lambdalifting.nim
@@ -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:
diff --git a/tests/closure/tclosure_issues.nim b/tests/closure/tclosure_issues.nim
index b2d77c571..d9416e554 100644
--- a/tests/closure/tclosure_issues.nim
+++ b/tests/closure/tclosure_issues.nim
@@ -1,5 +1,6 @@
 discard """
-  output: '''true'''
+  output: '''true
+(999, 0)'''
 """
 
 
@@ -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()()
\ No newline at end of file