Skip to content

Commit

Permalink
fix(codegen): missing parens for in in for in loop init (#7705)
Browse files Browse the repository at this point in the history
Well, this looks like an accidental change before, `Context::empty().and_forbid_in(false)` does nothing at all.
  • Loading branch information
Dunqing committed Dec 6, 2024
1 parent 4afbe55 commit 8c3a954
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion crates/oxc_codegen/src/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ impl Gen for ForInStatement<'_> {
p.print_str("for");
p.print_soft_space();
p.print_ascii_byte(b'(');
self.left.print(p, Context::empty().and_forbid_in(false));
self.left.print(p, Context::FORBID_IN);
p.print_soft_space();
p.print_space_before_identifier();
p.print_str("in");
Expand Down
8 changes: 4 additions & 4 deletions crates/oxc_codegen/tests/integration/unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ fn for_stmt() {
"for (x = (y in z) || y || (y in z) || y || (y in z);;);",
"for (x = (y in z) || y || (y in z) || y || (y in z);;);\n",
);
// test(
// "for (var a = 1 || (2 in {}) in { x: 1 }) count++;",
// "for (var a = 1 || (2 in {}) in {x: 1}) count++;\n",
// );
test(
"for (var a = 1 || (2 in {}) in { x: 1 }) count++;",
"for (var a = 1 || (2 in {}) in { x: 1 }) count++;\n",
);
}

#[test]
Expand Down

0 comments on commit 8c3a954

Please sign in to comment.