mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
fix(codegen): missing parenthesis for PrivateInExpression (#4865)
This commit is contained in:
parent
1808529a0c
commit
3da33d3647
2 changed files with 15 additions and 7 deletions
|
|
@ -1054,7 +1054,7 @@ impl<'a, const MINIFY: bool> GenExpr<MINIFY> for Expression<'a> {
|
|||
Self::UpdateExpression(expr) => expr.gen_expr(p, precedence, ctx),
|
||||
Self::UnaryExpression(expr) => expr.gen_expr(p, precedence, ctx),
|
||||
Self::BinaryExpression(expr) => expr.gen_expr(p, precedence, ctx),
|
||||
Self::PrivateInExpression(expr) => expr.gen(p, ctx),
|
||||
Self::PrivateInExpression(expr) => expr.gen_expr(p, precedence, ctx),
|
||||
Self::LogicalExpression(expr) => expr.gen_expr(p, precedence, ctx),
|
||||
Self::ConditionalExpression(expr) => expr.gen_expr(p, precedence, ctx),
|
||||
Self::AssignmentExpression(expr) => expr.gen_expr(p, precedence, ctx),
|
||||
|
|
@ -1778,11 +1778,13 @@ impl<const MINIFY: bool> Gen<MINIFY> for BinaryOperator {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, const MINIFY: bool> Gen<MINIFY> for PrivateInExpression<'a> {
|
||||
fn gen(&self, p: &mut Codegen<{ MINIFY }>, ctx: Context) {
|
||||
self.left.gen(p, ctx);
|
||||
p.print_str(" in ");
|
||||
self.right.gen_expr(p, Precedence::Shift, Context::empty());
|
||||
impl<'a, const MINIFY: bool> GenExpr<MINIFY> for PrivateInExpression<'a> {
|
||||
fn gen_expr(&self, p: &mut Codegen<{ MINIFY }>, precedence: Precedence, ctx: Context) {
|
||||
p.wrap(precedence >= Precedence::Compare, |p| {
|
||||
self.left.gen(p, ctx);
|
||||
p.print_str(" in ");
|
||||
self.right.gen_expr(p, Precedence::Equals, Context::empty());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,8 +9,14 @@ fn module_decl() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn new_expr() {
|
||||
fn expr() {
|
||||
test("new (foo()).bar();", "new (foo()).bar();\n");
|
||||
test(
|
||||
"class Foo { #test
|
||||
bar() { if (!(#test in Foo)) { } }
|
||||
}",
|
||||
"class Foo {\n\t#test;\n\tbar() {\n\t\tif (!(#test in Foo)) {}\n\t}\n}\n",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Reference in a new issue