From be53c4838b407d3edd61be11ba5f7af3d843f97b Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Mon, 6 Jun 2022 16:36:19 +0100 Subject: [PATCH] fix corner case in `collapse_vars` (#5494) fixes #5493 --- lib/compress.js | 1 + test/compress/awaits.js | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/lib/compress.js b/lib/compress.js index 6d9f2c48..27ac4fe9 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -2831,6 +2831,7 @@ Compressor.prototype.compress = function(node) { } return find_stop_logical(parent, op, level); } + if (parent instanceof AST_Await) return find_stop_value(parent, level + 1); if (parent instanceof AST_Binary) { var op; if (parent.left === node || !lazy_op[op = parent.operator]) { diff --git a/test/compress/awaits.js b/test/compress/awaits.js index 1bc008f9..3a436e72 100644 --- a/test/compress/awaits.js +++ b/test/compress/awaits.js @@ -2961,3 +2961,24 @@ issue_5478: { expect_stdout: "PASS" node_version: ">=8" } + +issue_5493: { + options = { + collapse_vars: true, + reduce_vars: true, + } + input: { + (async function(a) { + var b = await [ 42 || b, a = b ]; + console.log(a); + })(); + } + expect: { + (async function(a) { + var b = await [ 42 || b, a = b ]; + console.log(a); + })(); + } + expect_stdout: "undefined" + node_version: ">=8" +}