From 43498769f09e682af27999e138ab2d42cea5ef6e Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Fri, 29 May 2020 15:10:36 +0100 Subject: [PATCH] fix corner case in `evaluate` (#3936) fixes #3935 --- lib/compress.js | 2 +- test/compress/evaluate.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) 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" +} -- 2.34.1