maxtaco / coffee-script

IcedCoffeeScript
http://maxtaco.github.com/coffee-script
MIT License
727 stars 58 forks source link

Disappearing variable #146

Closed boris-petrov closed 9 years ago

boris-petrov commented 9 years ago
f = (callback) ->
  callback null, 2

test = (a, callback) ->
  console.log a
  while true
    console.log a
    await f defer(error, a)
    console.log a
    break

test 1, (error, a) ->
  console.log a

This prints:

1
undefined
2

While it should print:

1
1
2

Using the a variable in any way after the while in the test function fixes the problem.