From: Alex Lam S.L Date: Fri, 29 May 2020 14:10:36 +0000 (+0100) Subject: fix corner case in `evaluate` (#3936) X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=43498769f09e682af27999e138ab2d42cea5ef6e;p=UglifyJS.git fix corner case in `evaluate` (#3936) fixes #3935 --- diff --git a/lib/compress.js b/lib/compress.js index b82ac811..443a6491 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -3430,7 +3430,7 @@ merge(Compressor.prototype, { var v = e._eval(compressor, ignore_side_effects, cached, depth + 1); if (v === e) return this; modified(e); - return v; + return +v; }); var non_converting_binary = makePredicate("&& || === !=="); def(AST_Binary, function(compressor, ignore_side_effects, cached, depth) { diff --git a/test/compress/evaluate.js b/test/compress/evaluate.js index a7b5a4a5..97b39407 100644 --- a/test/compress/evaluate.js +++ b/test/compress/evaluate.js @@ -2654,3 +2654,18 @@ issue_3933: { } expect_stdout: "PASS" } + +issue_3935: { + options = { + evaluate: true, + } + input: { + console.log(function f(a) { + return a++; + }()); + } + expect: { + console.log(NaN); + } + expect_stdout: "NaN" +}