maxtaco / coffee-script

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

? doesn't check for undefined in indented await #80

Closed neverfox closed 11 years ago

neverfox commented 11 years ago

Maybe I'm missing something about how CS works but if I write:

await myMethod item, defer err, result
if err?
...

then if err? gets compiled as if (typeof err !== "undefined" && err !== null)

But if I write:

await
  for item in items 
    myMethod item, defer err, result
    if err?
    ...

then if err? gets compiled as if (err != null). Is this expected behavior?

neverfox commented 11 years ago

So this seems to be a CS thing that detects if err ever had a value assigned, which is ambiguous in the first case and not in the second, given the way ICS compiles the loop with an err = arguments[0].