This repository was archived by the owner on Feb 1, 2025. It is now read-only.
Remove old bindings when hoisting vars#368
Merged
benjamn merged 3 commits intofacebook:masterfrom Mar 20, 2019
Merged
Conversation
benjamn
approved these changes
Mar 7, 2019
Co-Authored-By: nicolo-ribaudo <nicolo.ribaudo@gmail.com>
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes babel/babel#6923, fixes babel/babel#8899, fixes babel/babel#8525
When hoisting variables, regenerator transforms
let a = 2;toa = 2;and then injectsvar aat the beginning of the generator function scope.Babel isn't really good at keeping the scope synchronized with the AST (and we won't fix it for a long time; it's probably the hardest thing to fix): for this reason, sometimes it throws when injecting
var abecause it thinks thatlet ais still there.Manually removing the old bindings fixes the bug.
Note that this bug is only present when using
regenerator-transformwithout@babel/plugin-transform-block-scoping(and thus it isn't reproducible when usingregenerator-preset), because@babel/plugin-transform-block-scopingtransformslet->varandvars can be duplicated.From babel/babel#6923:
Before this PR:
After this PR: