From 5b5f6e329cdaab4c8e89ad1d1c4c8f588d65e6a6 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Thu, 8 Sep 2022 03:49:40 +0100 Subject: [PATCH] fix corner case in `ie` (#5652) fixes #5651 --- lib/scope.js | 5 +++-- test/compress/default-values.js | 25 +++++++++++++++++++++++++ test/compress/destructured.js | 25 +++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 2 deletions(-) diff --git a/lib/scope.js b/lib/scope.js index e3e4248d8e2..c2108c50f16 100644 --- a/lib/scope.js +++ b/lib/scope.js @@ -369,8 +369,9 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) { // pass 3: fix up any scoping issue with IE8 if (options.ie) self.walk(new TreeWalker(function(node) { if (node instanceof AST_SymbolCatch) { - var scope = node.thedef.defun; - if (scope.name instanceof AST_SymbolLambda && scope.name.name == node.name) { + var def = node.thedef; + var scope = def.defun; + if (def.name != "arguments" && scope.name instanceof AST_SymbolLambda && scope.name.name == def.name) { scope = scope.parent_scope.resolve(); } redefine(node, scope); diff --git a/test/compress/default-values.js b/test/compress/default-values.js index ac2be8400d7..38f6552da13 100644 --- a/test/compress/default-values.js +++ b/test/compress/default-values.js @@ -3044,3 +3044,28 @@ issue_5566_5: { expect_stdout: "foo bar" node_version: ">=6" } + +issue_5651: { + options = { + ie: true, + unused: true, + } + input: { + console.log(function arguments(a = "FAIL") { + try {} catch (arguments) { + var arguments; + } + return arguments[0]; + }()); + } + expect: { + console.log(function arguments(a = "FAIL") { + try {} catch (arguments) { + var arguments; + } + return arguments[0]; + }()); + } + expect_stdout: true + node_version: ">=6" +} diff --git a/test/compress/destructured.js b/test/compress/destructured.js index 284130d7a53..f79570f35b0 100644 --- a/test/compress/destructured.js +++ b/test/compress/destructured.js @@ -3844,3 +3844,28 @@ issue_5573: { ] node_version: ">=6" } + +issue_5651: { + options = { + ie: true, + unused: true, + } + input: { + console.log(function arguments({}) { + try {} catch (arguments) { + var arguments; + } + return arguments[0]; + }("PASS")); + } + expect: { + console.log(function arguments({}) { + try {} catch (arguments) { + var arguments; + } + return arguments[0]; + }("PASS")); + } + expect_stdout: true + node_version: ">=6" +}