From: Alex Lam S.L Date: Sun, 20 Dec 2020 02:31:32 +0000 (+0000) Subject: fix corner case with destructuring `catch` (#4426) X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=f5224ca1f5075d6912616675f1aa7fa8cc7741f1;p=UglifyJS.git fix corner case with destructuring `catch` (#4426) fixes #4425 --- diff --git a/lib/scope.js b/lib/scope.js index 779637cb..c59dc0a7 100644 --- a/lib/scope.js +++ b/lib/scope.js @@ -255,7 +255,9 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) { i = in_arg.lastIndexOf(sym.scope, i - 1); if (i < 0) break; var decl = sym.orig[0]; - if (decl instanceof AST_SymbolFunarg || decl instanceof AST_SymbolLambda) { + if (decl instanceof AST_SymbolCatch + || decl instanceof AST_SymbolFunarg + || decl instanceof AST_SymbolLambda) { node.in_arg = true; break; } diff --git a/test/compress/destructured.js b/test/compress/destructured.js index 06c9fddb..d36bbf33 100644 --- a/test/compress/destructured.js +++ b/test/compress/destructured.js @@ -2001,3 +2001,39 @@ issue_4420: { expect_stdout: "PASS" node_version: ">=8" } + +issue_4425: { + rename = true + input: { + var a; + console.log(function() { + try { + try { + throw 42; + } catch ({ + [a]: a, + }) {} + return "FAIL"; + } catch (e) { + return "PASS"; + } + }()); + } + expect: { + var a; + console.log(function() { + try { + try { + throw 42; + } catch ({ + [b]: b, + }) {} + return "FAIL"; + } catch (c) { + return "PASS"; + } + }()); + } + expect_stdout: "PASS" + node_version: ">=8" +}