From b1279a46d9801bbc3eee8c4ea90422dd7582b928 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Thu, 17 Oct 2019 09:57:50 +0800 Subject: fix corner case in `sequences` (#3491) fixes #3490 --- test/compress/sequences.js | 63 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) (limited to 'test/compress') diff --git a/test/compress/sequences.js b/test/compress/sequences.js index 08a06790..fbca559a 100644 --- a/test/compress/sequences.js +++ b/test/compress/sequences.js @@ -1006,3 +1006,66 @@ angularjs_chain: { } } } + +issue_3490_1: { + options = { + conditionals: true, + dead_code: true, + inline: true, + sequences: true, + side_effects: true, + toplevel: true, + } + input: { + var b = 42, c = "FAIL"; + if ({ + 3: function() { + var a; + return (a && a.p) < this; + }(), + }) c = "PASS"; + if (b) while ("" == typeof d); + console.log(c, b); + } + expect: { + var b = 42, c = "FAIL"; + if (function() { + var a; + a && a.p; + }(), c = "PASS", b) while ("" == typeof d); + console.log(c, b); + } + expect_stdout: "PASS 42" +} + +issue_3490_2: { + options = { + conditionals: true, + dead_code: true, + evaluate: true, + inline: true, + reduce_vars: true, + sequences: true, + side_effects: true, + toplevel: true, + } + input: { + var b = 42, c = "FAIL"; + if ({ + 3: function() { + var a; + return (a && a.p) < this; + }(), + }) c = "PASS"; + if (b) for (; "" == typeof d;); + console.log(c, b); + } + expect: { + var b = 42, c = "FAIL"; + for (function() { + var a; + }(), c = "PASS", b; "" == typeof d;); + console.log(c, b); + } + expect_stdout: "PASS 42" +} -- cgit v1.2.3