From d316fb139da73ce299cd90e22ec742fdebe87d04 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Wed, 14 Feb 2018 16:48:47 +0800 Subject: fix `unsafe` `evaluate` on type-converting operators (#2917) fixes #2916 --- test/compress/evaluate.js | 60 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'test') diff --git a/test/compress/evaluate.js b/test/compress/evaluate.js index 41b599ed..3ac62ef5 100644 --- a/test/compress/evaluate.js +++ b/test/compress/evaluate.js @@ -1429,3 +1429,63 @@ string_case: { "199", ] } + +issue_2916_1: { + options = { + evaluate: true, + reduce_vars: true, + unsafe: true, + } + input: { + var c = "PASS"; + (function(a, b) { + (function(d) { + d[0] = 1; + })(b); + a == b && (c = "FAIL"); + })("", []); + console.log(c); + } + expect: { + var c = "PASS"; + (function(a, b) { + (function(d) { + d[0] = 1; + })(b); + a == b && (c = "FAIL"); + })("", []); + console.log(c); + } + expect_stdout: "PASS" +} + +issue_2916_2: { + options = { + collapse_vars: true, + evaluate: true, + inline: true, + reduce_vars: true, + side_effects: true, + unsafe: true, + unused: true, + } + input: { + var c = "FAIL"; + (function(b) { + (function(d) { + d[0] = 1; + })(b); + +b && (c = "PASS"); + })([]); + console.log(c); + } + expect: { + var c = "FAIL"; + (function(b) { + b[0] = 1; + +b && (c = "PASS"); + })([]); + console.log(c); + } + expect_stdout: "PASS" +} -- cgit v1.2.3