From d2c50ace997da8b1f7a3b0bd75bd1b376907928a Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Fri, 18 Dec 2020 04:20:43 +0000 Subject: [PATCH] fix corner case in `merge_vars` (#4402) fixes #4401 --- lib/compress.js | 6 +++++- test/compress/arrows.js | 25 +++++++++++++++++++++++++ test/ufuzz/index.js | 2 +- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/lib/compress.js b/lib/compress.js index 33d8cf55..ab5ad06d 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -4915,7 +4915,11 @@ merge(Compressor.prototype, { argname.mark_symbol(marker, scanner); }); } - walk_body(node, tw); + if (node instanceof AST_Arrow && node.value) { + node.value.walk(tw); + } else { + walk_body(node, tw); + } pop(); return true; } diff --git a/test/compress/arrows.js b/test/compress/arrows.js index dd71fe9b..c91cd275 100644 --- a/test/compress/arrows.js +++ b/test/compress/arrows.js @@ -465,3 +465,28 @@ issue_4390: { ] node_version: ">=4" } + +issue_4401: { + options = { + merge_vars: true, + } + input: { + (function() { + var a = (b => b(a))(console.log || a); + var c = console.log; + c && c(typeof b); + })(); + } + expect: { + (function() { + var a = (b => b(a))(console.log || a); + var c = console.log; + c && c(typeof b); + })(); + } + expect_stdout: [ + "undefined", + "undefined", + ] + node_version: ">=4" +} diff --git a/test/ufuzz/index.js b/test/ufuzz/index.js index c4ad4a78..eb38a759 100644 --- a/test/ufuzz/index.js +++ b/test/ufuzz/index.js @@ -1011,7 +1011,7 @@ function _createExpression(recurmax, noComma, stmtDepth, canThrow) { suffix = "})"; } else { s.push("((" + params + ") => "); - switch (rng(4)) { + switch (rng(10)) { case 0: s.push('(typeof arguments != "undefined" && arguments && arguments[' + rng(3) + "])"); break; -- 2.34.1