Wrong handling of questionable shadowing case
SonOfLilit opened this issue · comments
I'm not even sure what is considered the "correct" behavior in JS, only that it worked great for me and I wasn't even aware that I did this until I ran js2coffee and got buggy code:
var f = function(x) {
var ff = function() { return x; };
var x = 1;
};
The generated code is:
f = (x) ->
ff = ->
`var x`
x
x = 1
return
# ---
# generated by js2coffee 2.1.0
It can be fixed by removing that var x
. Or I would be perfectly happy if the warning it gave me about shadowing in this case would instead be an error, since this "shadowing" is definitely not what I intended (and I fixed it in my JS when I saw the warning while minimizing a test case for the bug report.)
But buggy code is a bummer.