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

Function created in deconstruction in catch clause cannot access other vars from catch clause #322

Open
overlookmotel opened this issue Dec 3, 2021 · 2 comments
Labels
bug Something isn't working maybe fixed Maybe fixed but needs tests

Comments

@overlookmotel
Copy link
Owner

Input:

let fn;
try {
  throw new Error('foo');
} catch ( { message, x = (0, () => message) } ) {
  fn = x;
}
export default fn;

Output:

export default () => message;

message has not been recognised as a var in scope of the function.

Appears to be in part due to a bug in Babel. identifierPath.scope.getBinding('message') returns undefined.

@overlookmotel overlookmotel added the bug Something isn't working label Dec 3, 2021
@overlookmotel
Copy link
Owner Author

Babel issue: babel/babel#14024

@overlookmotel
Copy link
Owner Author

I think fixed in b2a0a09. Needs tests.

@overlookmotel overlookmotel added the maybe fixed Maybe fixed but needs tests label Mar 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working maybe fixed Maybe fixed but needs tests
Projects
None yet
Development

No branches or pull requests

1 participant