rewrote lambdalifting; fixes deeply nested closures
This commit is contained in:
parent
e712dbaef5
commit
eed443d4b3
15 changed files with 458 additions and 298 deletions
36
tests/closure/tnestedclosure.nim
Normal file
36
tests/closure/tnestedclosure.nim
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
discard """
|
||||
output: '''foo88
|
||||
23 24foo 88
|
||||
foo88
|
||||
23 24foo 88'''
|
||||
"""
|
||||
|
||||
# test nested closure
|
||||
proc main(param: int) =
|
||||
var foo = 23
|
||||
proc outer(outerParam: string) =
|
||||
var outerVar = 88
|
||||
echo outerParam, outerVar
|
||||
proc inner() =
|
||||
block Test:
|
||||
echo foo, " ", param, outerParam, " ", outerVar
|
||||
inner()
|
||||
outer("foo")
|
||||
|
||||
# test simple closure within dummy 'main':
|
||||
proc dummy =
|
||||
proc main2(param: int) =
|
||||
var foo = 23
|
||||
proc outer(outerParam: string) =
|
||||
var outerVar = 88
|
||||
echo outerParam, outerVar
|
||||
proc inner() =
|
||||
block Test:
|
||||
echo foo, " ", param, outerParam, " ", outerVar
|
||||
inner()
|
||||
outer("foo")
|
||||
main2(24)
|
||||
|
||||
dummy()
|
||||
|
||||
main(24)
|
||||
Loading…
Add table
Add a link
Reference in a new issue