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: do not remove shadowed for-loop declarators #11242

Merged
merged 2 commits into from Mar 12, 2020

Conversation

JLHwung
Copy link
Contributor

@JLHwung JLHwung commented Mar 11, 2020

Q                       A
Fixed Issues? Fixes #11231
Patch: Bug Fix? Y
Tests Added + Pass? Yes
License MIT

Whitelist var declarator in for loop when we are removing shadowed uninitialized variable declarators.

This PR is a follow-up to #11158 .

@JLHwung JLHwung added the PR: Bug Fix 🐛 A type of pull request used for our changelog categories label Mar 11, 2020
@JLHwung JLHwung added this to the v7.8.8 milestone Mar 11, 2020
state.iife = true;
// for (var x in {}); should not be removed
const declaration = redeclarator.parentPath;
if (!declaration.parentPath.isFor({ left: declaration.node })) {
Copy link
Member

Choose a reason for hiding this comment

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

In for (...;...;...) statements left doesn't exist: it's called init.
If you meant to only check for-of and for-in (but I don't think so), then you need ForXStatement.

💡 Idea: an ESLint plugin that prevents us from checking non-existent properties (like in this case).

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.

I'll release a patch version when this is merged.

@JLHwung JLHwung merged commit 565ab9a into babel:master Mar 12, 2020
@JLHwung JLHwung deleted the fix-11231 branch March 12, 2020 18:08
@nicolo-ribaudo
Copy link
Member

Release is coming!

@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jun 12, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Bug Fix 🐛 A type of pull request used for our changelog categories
Projects
None yet
3 participants