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

fix: Exclude catch clause from let identifier error #10559

Merged
merged 5 commits into from Oct 17, 2019
Merged

fix: Exclude catch clause from let identifier error #10559

merged 5 commits into from Oct 17, 2019

Conversation

zant
Copy link
Contributor

@zant zant commented Oct 15, 2019

Q                       A
Fixed Issues? Fixes #10413
Patch: Bug Fix? Yes
Major: Breaking Change? No
Minor: New Feature? No
Tests Added + Pass? Yes
Any Dependency Changes? No
License MIT

I added a new getter in scope to know if the current scope is a catch block, and then use that property to exclude catch blocks from the original condition

I also tried to go the other way around and implicitly exclude the catch block by raising the error not on lexical binding, but only on let and const declarations, but i couldn’t find a way to check the kind of the variable declaration when handling an identifier's name

I think other solution could be adding a new scope flag for catch blocks, but i'm not really sure

What do you guys think?

@zant zant changed the title Exclude catch clause from let identifier error fix: Exclude catch clause from let identifier error Oct 15, 2019
@nicolo-ribaudo nicolo-ribaudo added pkg: parser PR: Spec Compliance 👓 A type of pull request used for our changelog categories labels Oct 15, 2019
@zant zant marked this pull request as ready for review October 16, 2019 16:32
Copy link
Member

@nicolo-ribaudo nicolo-ribaudo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 (one nit)

packages/babel-parser/src/parser/statement.js Outdated Show resolved Hide resolved
Co-Authored-By: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: parser PR: Spec Compliance 👓 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[parser] let in catch clause is not an error in sloppy
3 participants