From dfc3ec9cef2f8dad08471cf636f52387045b342d Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Thu, 24 Dec 2020 19:58:23 +0000 Subject: [PATCH] fix corner case in `pure_getters` (#4449) fixes #4448 --- lib/compress.js | 1 + test/compress/arrows.js | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/lib/compress.js b/lib/compress.js index 29cd26b6..2c1f87d1 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -358,6 +358,7 @@ merge(Compressor.prototype, { function is_arguments(def) { if (def.name != "arguments") return false; + if (!def.scope.uses_arguments) return false; var orig = def.orig; return orig.length == 1 && orig[0] instanceof AST_SymbolFunarg; } diff --git a/test/compress/arrows.js b/test/compress/arrows.js index cc5aec5f..990090b2 100644 --- a/test/compress/arrows.js +++ b/test/compress/arrows.js @@ -587,3 +587,32 @@ issue_4401: { ] node_version: ">=4" } + +issue_4448: { + options = { + pure_getters: "strict", + side_effects: true, + } + input: { + var A; + try { + (arguments => { + arguments[0]; + })(A); + } catch (e) { + console.log("PASS"); + } + } + expect: { + var A; + try { + (arguments => { + arguments[0]; + })(A); + } catch (e) { + console.log("PASS"); + } + } + expect_stdout: "PASS" + node_version: ">=4" +} -- 2.34.1