Skip to content

Commit

Permalink
fix(codegen): invalid codegen when in inside bin expr in or loop
Browse files Browse the repository at this point in the history
  • Loading branch information
camc314 committed Oct 10, 2024
1 parent 2531490 commit e44af02
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion crates/oxc_codegen/src/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1740,7 +1740,7 @@ impl<'a> GenExpr for LogicalExpression<'a> {
precedence,
ctx,
left_precedence: Precedence::Lowest,
left_ctx: Context::empty(),
left_ctx: ctx,
operator: BinaryishOperator::Logical(self.operator),
wrap: false,
right_precedence: Precedence::Lowest,
Expand Down
5 changes: 5 additions & 0 deletions crates/oxc_codegen/tests/integration/unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,4 +279,9 @@ fn in_expr_in_sequence_in_for_loop_init() {
"for (l = ('foo' in bar), i; i < 10; i += 1) {}",
"for (l = (\"foo\" in bar), i; i < 10; i += 1) {}\n",
);

test(
"for (('hidden' in a) && (m = a.hidden), r = 0; s > r; r++) {}",
"for ((\"hidden\" in a) && (m = a.hidden), r = 0; s > r; r++) {}\n",
);
}

0 comments on commit e44af02

Please sign in to comment.