From 0eb0c9b388a17fbadd9f74a15effe7477695d5e6 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Mon, 24 Aug 2020 07:57:26 +0100 Subject: [PATCH] fix corner case in `evaluate` (#4068) fixes #4067 --- lib/compress.js | 1 + test/compress/evaluate.js | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/lib/compress.js b/lib/compress.js index 3291f167..acc85021 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -3568,6 +3568,7 @@ merge(Compressor.prototype, { escaped[0].walk(new TreeWalker(function(node) { if (found) return true; if (node === ref) return found = true; + if (node instanceof AST_Scope) return true; })); return found; default: diff --git a/test/compress/evaluate.js b/test/compress/evaluate.js index b5b74ac0..9f97ba99 100644 --- a/test/compress/evaluate.js +++ b/test/compress/evaluate.js @@ -2869,3 +2869,28 @@ issue_4035: { "true", ] } + +issue_4067: { + options = { + evaluate: true, + reduce_vars: true, + unsafe: true, + } + input: { + (function(a) { + (function(b) { + b[0] += 0; + console.log(+a); + })(a); + })([]); + } + expect: { + (function(a) { + (function(b) { + b[0] += 0; + console.log(+a); + })(a); + })([]); + } + expect_stdout: "NaN" +} -- 2.34.1