diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2019-06-26 23:41:20 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2019-06-26 23:41:20 +0200 |
commit | 135fdde6a9108591fa4c921bd0ad37179b10cc02 (patch) | |
tree | f8496c8badbbb2d5dd70f7d87c2cfd9937de67c6 | |
parent | 19b142401c9c7eece2cab7539ef626dc52a156fd (diff) | |
download | Nim-135fdde6a9108591fa4c921bd0ad37179b10cc02.tar.gz |
fixes #11523
-rw-r--r-- | compiler/lambdalifting.nim | 3 | ||||
-rw-r--r-- | tests/closure/tclosure_issues.nim | 11 |
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 |