mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
fix(codegen): do not print parenthesis for in expression in ArrowFunctionExpression (#7360)
Please check out [esbuild](https://esbuild.github.io/try/#dAAwLjI0LjAAACgpID0+ICIiIGluIHt9)
This commit is contained in:
parent
514878d927
commit
c587dd3cd6
2 changed files with 8 additions and 1 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue