From 9074f05129318c2acc095d8a58c60c0a61ff0cee Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Thu, 5 Dec 2019 05:08:37 +0800 Subject: fix corner case in `collapse_vars` (#3629) fixes #3628 --- test/compress/collapse_vars.js | 54 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'test') diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js index 9fe5a93f..16cbadf8 100644 --- a/test/compress/collapse_vars.js +++ b/test/compress/collapse_vars.js @@ -7345,3 +7345,57 @@ issue_3626_2: { } expect_stdout: "foo 42 null" } + +issue_3628_1: { + options = { + collapse_vars: true, + } + input: { + var a = "bar", b; + ({ + get p() { + a = "foo"; + }, + q: b = a + }).p; + console.log(a, b); + } + expect: { + var a = "bar", b; + ({ + get p() { + a = "foo"; + }, + q: b = a + }).p; + console.log(a, b); + } + expect_stdout: "foo bar" +} + +issue_3628_2: { + options = { + collapse_vars: true, + } + input: { + var a = "bar", b; + ({ + get p() { + a = "foo"; + }, + q: (b = a, 42) + }).p; + console.log(a, b); + } + expect: { + var a = "bar", b; + ({ + get p() { + a = "foo"; + }, + q: (b = a, 42) + }).p; + console.log(a, b); + } + expect_stdout: "foo bar" +} -- cgit v1.2.3