From 8a83c8dd46dc8e446cd7231116a06c8b217291b7 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Tue, 17 Nov 2020 08:23:50 +0000 Subject: fix corner cases in `collapse_vars` & `dead_code` (#4285) fixes #4284 --- test/compress/destructured.js | 62 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) (limited to 'test') diff --git a/test/compress/destructured.js b/test/compress/destructured.js index 65429b92..1555e3e3 100644 --- a/test/compress/destructured.js +++ b/test/compress/destructured.js @@ -1341,3 +1341,65 @@ issue_4282: { expect_stdout: true node_version: ">=6" } + +issue_4284_1: { + options = { + dead_code: true, + } + input: { + var a, { + 0: b, + } = a = "foo"; + console.log(a, b); + } + expect: { + var a, { + 0: b, + } = a = "foo"; + console.log(a, b); + } + expect_stdout: "foo f" + node_version: ">=6" +} + +issue_4284_2: { + options = { + collapse_vars: true, + } + input: { + var a, { + [console.log(a)]: b, + } = (a = "PASS", 0); + var c = a; + } + expect: { + var a, { + [console.log(a)]: b, + } = (a = "PASS", 0); + var c = a; + } + expect_stdout: "PASS" + node_version: ">=6" +} + +issue_4284_3: { + options = { + collapse_vars: true, + } + input: { + var a, b; + ({ + [console.log(a)]: b, + } = (a = "PASS", 0)); + var c = a; + } + expect: { + var a, b; + ({ + [console.log(a)]: b, + } = (a = "PASS", 0)); + var c = a; + } + expect_stdout: "PASS" + node_version: ">=6" +} -- cgit v1.2.3