Wrong handling of questionable shadowing case #418

SonOfLilit opened this Issue Nov 24, 2015 · 0 comments


None yet

1 participant


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 = 1

# ---
# 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment