From f31311e4394a505a041e5401149e4484c8114ec8 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Mon, 17 Jun 2024 06:38:16 +0300 Subject: [PATCH] fix corner case in `inline` (#5848) fixes #5844 --- lib/compress.js | 4 ++++ test/compress/destructured.js | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/lib/compress.js b/lib/compress.js index e161f46d..26dc1505 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -11162,6 +11162,10 @@ Compressor.prototype.compress = function(node) { return; } if (node instanceof AST_Class) return abort = true; + if (node instanceof AST_Destructured) { + side_effects = true; + return; + } if (node instanceof AST_Scope) return abort = true; if (avoid && node instanceof AST_Symbol && avoid[node.name]) return abort = true; if (node instanceof AST_SymbolRef) { diff --git a/test/compress/destructured.js b/test/compress/destructured.js index 55932111..8b394b0e 100644 --- a/test/compress/destructured.js +++ b/test/compress/destructured.js @@ -3937,3 +3937,25 @@ issue_5843_2: { expect_stdout: "PASS" node_version: ">=6" } + +issue_5844: { + options = { + inline: true, + } + input: { + try { + (function(a) { + [ a.p ] = 42; + })(console.log("PASS")); + } catch (e) {} + } + expect: { + try { + (function(a) { + [ a.p ] = 42; + })(console.log("PASS")); + } catch (e) {} + } + expect_stdout: "PASS" + node_version: ">=6" +}