mirror of
https://github.com/swc-project/swc.git
synced 2024-12-01 09:52:57 +03:00
fix(es/transforms/base): Wrap binary operands of unary expressions. (#1793)
swc_ecma_transforms_base: - `fixer`: Handle binary operands of unary expressions correctly. (#1789)
This commit is contained in:
parent
0bd2a3a07e
commit
03db7adc9f
@ -6,7 +6,7 @@ edition = "2018"
|
||||
license = "Apache-2.0/MIT"
|
||||
name = "swc_ecmascript"
|
||||
repository = "https://github.com/swc-project/swc.git"
|
||||
version = "0.36.1"
|
||||
version = "0.36.2"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
@ -33,7 +33,7 @@ swc_ecma_codegen = {version = "0.55.0", path = "./codegen", optional = true}
|
||||
swc_ecma_dep_graph = {version = "0.25.0", path = "./dep-graph", optional = true}
|
||||
swc_ecma_minifier = {version = "0.2.3", path = "./minifier", optional = true}
|
||||
swc_ecma_parser = {version = "0.57.0", path = "./parser", optional = true}
|
||||
swc_ecma_transforms = {version = "0.50.1", path = "./transforms", optional = true}
|
||||
swc_ecma_transforms = {version = "0.50.2", path = "./transforms", optional = true}
|
||||
swc_ecma_utils = {version = "0.36.0", path = "./utils", optional = true}
|
||||
swc_ecma_visit = {version = "0.31.0", path = "./visit", optional = true}
|
||||
|
||||
|
@ -1 +1 @@
|
||||
console.log(-0, 0, -1 / 0, -1 / 0);
|
||||
console.log(-0, 0, -(1 / 0), -(1 / 0));
|
||||
|
@ -1 +1 @@
|
||||
console.log(-2 / 3);
|
||||
console.log(-(2 / 3));
|
||||
|
@ -13,6 +13,6 @@ var v = [
|
||||
];
|
||||
v.forEach(function(x) {
|
||||
v.forEach(function(y) {
|
||||
console.log(+(x * y), +x / y, +x % y, -(x * y), -x / y, -x % y);
|
||||
console.log(+(x * y), +(x / y), +(x % y), -(x * y), -(x / y), -(x % y));
|
||||
});
|
||||
});
|
||||
|
@ -6,7 +6,7 @@ edition = "2018"
|
||||
license = "Apache-2.0/MIT"
|
||||
name = "swc_ecma_transforms"
|
||||
repository = "https://github.com/swc-project/swc.git"
|
||||
version = "0.50.1"
|
||||
version = "0.50.2"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
@ -25,7 +25,7 @@ swc_atoms = {version = "0.2.0", path = "../../atoms"}
|
||||
swc_common = {version = "0.10.16", path = "../../common"}
|
||||
swc_ecma_ast = {version = "0.45.0", path = "../ast"}
|
||||
swc_ecma_parser = {version = "0.57.0", path = "../parser"}
|
||||
swc_ecma_transforms_base = {version = "0.15.6", path = "./base"}
|
||||
swc_ecma_transforms_base = {version = "0.15.7", path = "./base"}
|
||||
swc_ecma_transforms_compat = {version = "0.17.9", path = "./compat", optional = true}
|
||||
swc_ecma_transforms_module = {version = "0.17.1", path = "./module", optional = true}
|
||||
swc_ecma_transforms_optimization = {version = "0.20.3", path = "./optimization", optional = true}
|
||||
|
@ -6,7 +6,7 @@ edition = "2018"
|
||||
license = "Apache-2.0/MIT"
|
||||
name = "swc_ecma_transforms_base"
|
||||
repository = "https://github.com/swc-project/swc.git"
|
||||
version = "0.15.6"
|
||||
version = "0.15.7"
|
||||
|
||||
[dependencies]
|
||||
fxhash = "0.2.1"
|
||||
|
@ -277,10 +277,7 @@ impl VisitMut for Fixer<'_> {
|
||||
n.visit_mut_children_with(self);
|
||||
self.ctx = old;
|
||||
|
||||
match *n.arg {
|
||||
// Don't wrap
|
||||
Expr::Bin(BinExpr { op: op!("%"), .. }) | Expr::Bin(BinExpr { op: op!("/"), .. }) => {}
|
||||
|
||||
match &*n.arg {
|
||||
Expr::Assign(..)
|
||||
| Expr::Bin(..)
|
||||
| Expr::Seq(..)
|
||||
@ -1220,4 +1217,6 @@ var store = global[SHARED] || (global[SHARED] = {});
|
||||
identical!(minifier_004, "(void 0)(0)");
|
||||
|
||||
identical!(issue_1781, "const n = ~~(Math.PI * 10)");
|
||||
|
||||
identical!(issue_1789, "+(+1 / 4)");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user