From e44af02e3e322fb4a7f023920c4dfdf5f8cb4279 Mon Sep 17 00:00:00 2001 From: Cameron Clark Date: Thu, 10 Oct 2024 18:13:59 +0100 Subject: [PATCH] fix(codegen): invalid codegen when `in` inside bin expr in or loop --- crates/oxc_codegen/src/gen.rs | 2 +- crates/oxc_codegen/tests/integration/unit.rs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/oxc_codegen/src/gen.rs b/crates/oxc_codegen/src/gen.rs index 6497b22b2a9bfa..3018100f397304 100644 --- a/crates/oxc_codegen/src/gen.rs +++ b/crates/oxc_codegen/src/gen.rs @@ -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, diff --git a/crates/oxc_codegen/tests/integration/unit.rs b/crates/oxc_codegen/tests/integration/unit.rs index cfb574c0826258..702822be42c2d3 100644 --- a/crates/oxc_codegen/tests/integration/unit.rs +++ b/crates/oxc_codegen/tests/integration/unit.rs @@ -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", + ); }