mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
fix(codegen): print #field in {} << 0; correctly (#6799)
This commit is contained in:
parent
2f6ad42348
commit
1b7897cf01
4 changed files with 20 additions and 11 deletions
|
|
@ -196,6 +196,12 @@ impl<'a> BinaryExpressionVisitor<'a> {
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Expression::PrivateInExpression(e) = self.e.left() {
|
||||||
|
e.gen_expr(p, Precedence::Lowest, Context::empty());
|
||||||
|
self.visit_right_and_finish(p);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1700,7 +1700,7 @@ impl<'a> GenExpr for PrivateInExpression<'a> {
|
||||||
p.wrap(precedence >= Precedence::Compare, |p| {
|
p.wrap(precedence >= Precedence::Compare, |p| {
|
||||||
self.left.print(p, ctx);
|
self.left.print(p, ctx);
|
||||||
p.print_str(" in ");
|
p.print_str(" in ");
|
||||||
self.right.print_expr(p, Precedence::Equals, Context::empty());
|
self.right.print_expr(p, Precedence::Equals, Context::FORBID_IN);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,18 +11,24 @@ fn module_decl() {
|
||||||
#[test]
|
#[test]
|
||||||
fn expr() {
|
fn expr() {
|
||||||
test("new (foo()).bar();", "new (foo()).bar();\n");
|
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_minify("x in new Error()", "x in new Error();");
|
test_minify("x in new Error()", "x in new Error();");
|
||||||
|
|
||||||
test("1000000000000000128.0.toFixed(0)", "0xde0b6b3a7640080.toFixed(0);\n");
|
test("1000000000000000128.0.toFixed(0)", "0xde0b6b3a7640080.toFixed(0);\n");
|
||||||
test_minify("1000000000000000128.0.toFixed(0)", "0xde0b6b3a7640080.toFixed(0);");
|
test_minify("1000000000000000128.0.toFixed(0)", "0xde0b6b3a7640080.toFixed(0);");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn private_in() {
|
||||||
|
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(
|
||||||
|
"class Foo { #test; bar() { #field in {} << 0 } }",
|
||||||
|
"class Foo {\n\t#test;\n\tbar() {\n\t\t#field in {} << 0;\n\t}\n}\n",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn access_property() {
|
fn access_property() {
|
||||||
test(
|
test(
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ commit: 06454619
|
||||||
|
|
||||||
runtime Summary:
|
runtime Summary:
|
||||||
AST Parsed : 18446/18446 (100.00%)
|
AST Parsed : 18446/18446 (100.00%)
|
||||||
Positive Passed: 17183/18446 (93.15%)
|
Positive Passed: 17184/18446 (93.16%)
|
||||||
tasks/coverage/test262/test/annexB/language/function-code/block-decl-func-block-scoping.js
|
tasks/coverage/test262/test/annexB/language/function-code/block-decl-func-block-scoping.js
|
||||||
minify error: ReferenceError: f is not defined
|
minify error: ReferenceError: f is not defined
|
||||||
|
|
||||||
|
|
@ -1758,9 +1758,6 @@ minify error: Test262Error: The result of (1n > "0.") is false Expected SameValu
|
||||||
tasks/coverage/test262/test/language/expressions/greater-than-or-equal/bigint-and-incomparable-string.js
|
tasks/coverage/test262/test/language/expressions/greater-than-or-equal/bigint-and-incomparable-string.js
|
||||||
minify error: Test262Error: The result of (1n >= "0.") is false Expected SameValue(«true», «false») to be true
|
minify error: Test262Error: The result of (1n >= "0.") is false Expected SameValue(«true», «false») to be true
|
||||||
|
|
||||||
tasks/coverage/test262/test/language/expressions/in/private-field-rhs-non-object.js
|
|
||||||
codegen error: Test262Error: Expected SameValue(«null», «null») to be false
|
|
||||||
|
|
||||||
tasks/coverage/test262/test/language/expressions/less-than/bigint-and-incomparable-string.js
|
tasks/coverage/test262/test/language/expressions/less-than/bigint-and-incomparable-string.js
|
||||||
minify error: Test262Error: The result of ("0." < 1n) is false Expected SameValue(«true», «false») to be true
|
minify error: Test262Error: The result of ("0." < 1n) is false Expected SameValue(«true», «false») to be true
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue