From 135fdde6a9108591fa4c921bd0ad37179b10cc02 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Wed, 26 Jun 2019 23:41:20 +0200 Subject: [PATCH] fixes #11523 --- compiler/lambdalifting.nim | 3 ++- tests/closure/tclosure_issues.nim | 11 ++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/compiler/lambdalifting.nim b/compiler/lambdalifting.nim index 1d542d7f5f..29d6f122ef 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 b2d77c5716..d9416e5548 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