From 2045fe627397da217dc28fca52bd5cf85d42d2ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Sun, 14 Aug 2022 15:15:03 +0900 Subject: [PATCH] fix(es/minifier): Remove wrong code (#5485) --- crates/swc/tests/exec/next/39412/exec.js | 10 ++++++++++ crates/swc_ecma_minifier/src/compress/optimize/ops.rs | 5 ----- crates/swc_node_bundler/Cargo.toml | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 crates/swc/tests/exec/next/39412/exec.js diff --git a/crates/swc/tests/exec/next/39412/exec.js b/crates/swc/tests/exec/next/39412/exec.js new file mode 100644 index 00000000000..605b16c342e --- /dev/null +++ b/crates/swc/tests/exec/next/39412/exec.js @@ -0,0 +1,10 @@ +const a = true; +const b = true; +const c = false; +if (a && b && c) { + console.log('This shouldn\'t log'); +} +if (c && b && a) { + console.log('Reversed: This also shouldn\'t log'); +} +console.log('PASS') \ No newline at end of file diff --git a/crates/swc_ecma_minifier/src/compress/optimize/ops.rs b/crates/swc_ecma_minifier/src/compress/optimize/ops.rs index 8acdbdfe4eb..5b1e65c0e39 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/ops.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/ops.rs @@ -326,11 +326,6 @@ where report_change!("Optimizing: e && true => !!e"); self.negate_twice(&mut bin.left, false); - *e = *bin.left.take(); - } else { - self.changed = true; - report_change!("Optimizing: e && false => e"); - *e = *bin.left.take(); } } diff --git a/crates/swc_node_bundler/Cargo.toml b/crates/swc_node_bundler/Cargo.toml index 4de29653ae9..15067ff42ef 100644 --- a/crates/swc_node_bundler/Cargo.toml +++ b/crates/swc_node_bundler/Cargo.toml @@ -46,4 +46,4 @@ tracing = "0.1.32" [dev-dependencies] pretty_assertions = "1.1" -testing = { path = "../testing" } +testing = { version = "0.29.4", path = "../testing" }