Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reusing a variable in a catch() expression makes the variable undeclared #1595

Closed
josephg opened this issue Aug 11, 2011 · 2 comments
Closed

Comments

@josephg
Copy link

josephg commented Aug 11, 2011

This code:

try
  x = 3
catch x
  throw x

compiles to this:

try {
  x = 3;
} catch (x) {
  throw x;
}

... In which x is never declared locally.

@michaelficarra
Copy link
Collaborator

Looks like a bug to me. Simpler examples:

$ coffee -bpe 'try x = 3 catch x'
try {
  x = 3;
} catch (x) {

}
$ coffee -bpe 'try x = 3 catch y'
var x;
try {
  x = 3;
} catch (y) {

}

@jashkenas
Copy link
Owner

This patch should do the trick -- thanks for the bug report, and the great test case.

jashkenas added a commit that referenced this issue Aug 14, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants