Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Missing parenthesis in initializer of for loop #16628

Description

@nicolo-ribaudo

Describe the bug

Babel is removing some parentheses form this for loop, and the resulting code logs 0 instead of 1

Input code

let count = 0;
for (var a = 1 || (2 in {}) in { x: 1 }) count++;
console.log(count);

Expected behavior

Same code

Actual behavior

let count = 0;
for(var a = 1 || 2 in {} in {
    x: 1
})count++;
console.log(count);

Metadata

Metadata

Labels

outdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions