indutny / candor

Experimental VM for a `Candor` language
http://candor-lang.org/
177 stars 16 forks source link

nested scopes breaking variables #5

Closed creationix closed 12 years ago

creationix commented 12 years ago

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)
})()

https://github.com/creationix/candor.io/blob/master/examples/broken/functionAsArg.can

indutny commented 12 years ago

Thanks, fixed!