Skip to content

fix: Exclude catch clause from let identifier error#10559

Merged
nicolo-ribaudo merged 5 commits intobabel:masterfrom
zant:bugfix/10413
Oct 17, 2019
Merged

fix: Exclude catch clause from let identifier error#10559
nicolo-ribaudo merged 5 commits intobabel:masterfrom
zant:bugfix/10413

Conversation

@zant
Copy link
Copy Markdown
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
Copy Markdown
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)

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