diff --git a/crates/oxc_codegen/src/gen.rs b/crates/oxc_codegen/src/gen.rs index a7f1cc4d9..cbb5409f6 100644 --- a/crates/oxc_codegen/src/gen.rs +++ b/crates/oxc_codegen/src/gen.rs @@ -1623,7 +1623,7 @@ impl<'a> GenExpr for ArrowFunctionExpression<'a> { if self.expression { if let Some(Statement::ExpressionStatement(stmt)) = &self.body.statements.first() { p.start_of_arrow_expr = p.code_len(); - stmt.expression.print_expr(p, Precedence::Comma, ctx.and_forbid_in(true)); + stmt.expression.print_expr(p, Precedence::Comma, ctx); } } else { self.body.print(p, ctx); diff --git a/crates/oxc_codegen/tests/integration/unit.rs b/crates/oxc_codegen/tests/integration/unit.rs index cbd077a4e..17cf30bbe 100644 --- a/crates/oxc_codegen/tests/integration/unit.rs +++ b/crates/oxc_codegen/tests/integration/unit.rs @@ -294,3 +294,10 @@ fn in_expr_in_sequence_in_for_loop_init() { "for ((\"hidden\" in a) && (m = a.hidden), r = 0; s > r; r++) {}\n", ); } + +#[test] +fn in_expr_in_arrow_function_expression() { + test("() => ('foo' in bar)", "() => \"foo\" in bar;\n"); + test("() => 'foo' in bar", "() => \"foo\" in bar;\n"); + test("() => { ('foo' in bar) }", "() => {\n\t\"foo\" in bar;\n};\n"); +}