When a function has a scope inside a function it creates, strange things happen to the value of local variables. Also the number of scope names in the current scope affect how these variables change.
((fn) {
scope print
print("fn", fn)
fn2 = fn
return () {
// If I scope fn here, then fn in the parent becomes nil
// If I scope the alias fn2, then the local fn2 is 0
scope fn, fn2, print
print("fn2", fn2)
fn2(42)
}
})((num) {
scope print
print("num", num)
})()
When a function has a scope inside a function it creates, strange things happen to the value of local variables. Also the number of scope names in the current scope affect how these variables change.
https://github.com/creationix/candor.io/blob/master/examples/broken/functionAsArg.can