-
Notifications
You must be signed in to change notification settings - Fork 648
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make a separate LexicalScope for catch parameters
Summary: `catch` parameters are subject to similar scoping rules as actual function parameters. The previously functioning redeclaration logic has to be updated to account for the fact that the catch parameters are in a separate scope from the body of the catch. Instead of checking `topLevel`, we have to check `let`s in the top-level of the catch body itself against the Catch parameters. To do this, add a new `Decl::Kind` for ES6-style `Catch`, which lets us easily detect conflicts against the catch parameters. However, there's one complication due to scoped function promotion. We can promote scoped functions past ES5 catches, which wasn't being handled properly before because the ES5 catch binding was reusing the promoted `Var`'s `Decl`. What we actually want is to make a new `Decl` for the `ES5Catch`, and then _avoid_ reusing the catch's `Decl` when rebinding the scoped binding for the promoted function, instead using the `Var`. To facilitate this, we have to also store the promoted `Decl` for every promoted function and use that instead. In practice, this shouldn't increase memory usage much given how rarely we have to promote functions. Reviewed By: tmikov Differential Revision: D59021855 fbshipit-source-id: 33e59f35679f121da16f6bb527ffcdfe7197f686
- Loading branch information
1 parent
a4defc9
commit eee2d88
Showing
13 changed files
with
138 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.