From: Alex Lam S.L Date: Sat, 21 Oct 2017 20:19:40 +0000 (+0800) Subject: fix `unsafe` evaluation of objects (#2388) X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=4ae1fb3ed8380d06220fd242037bd277fc21c17d;p=UglifyJS.git fix `unsafe` evaluation of objects (#2388) --- diff --git a/lib/compress.js b/lib/compress.js index c7e08638..cef5d75f 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -4492,6 +4492,7 @@ merge(Compressor.prototype, { if (def) { return def.optimize(compressor); } + if (is_lhs(self, compressor.parent())) return self; if (compressor.option("unsafe") && self.expression instanceof AST_Object) { var values = self.expression.properties; for (var i = values.length; --i >= 0;) { diff --git a/test/compress/properties.js b/test/compress/properties.js index c2c43f69..c8a85697 100644 --- a/test/compress/properties.js +++ b/test/compress/properties.js @@ -804,3 +804,21 @@ issue_2256: { g.keep = g.g; } } + +lhs_prop: { + options = { + evaluate: true, + unsafe: true, + } + input: { + console.log(++{ + a: 1 + }.a); + } + expect: { + console.log(++{ + a: 1 + }.a); + } + expect_stdout: "2" +}