From: Alex Lam S.L Date: Wed, 10 Feb 2021 00:45:36 +0000 (+0000) Subject: fix corner case in `collapse_vars` (#4634) X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=5e6307974fa2b1e7972ab8c58b636eaed47a54fb;p=UglifyJS.git fix corner case in `collapse_vars` (#4634) fixes #4633 --- diff --git a/lib/compress.js b/lib/compress.js index c822a8e7..3fcfe2d2 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -2009,7 +2009,7 @@ merge(Compressor.prototype, { }; var tw = new TreeWalker(function(node) { if (!arg) return true; - if (has_await(node)) { + if (has_await(node) || node instanceof AST_Yield) { arg = null; return true; } diff --git a/test/compress/yields.js b/test/compress/yields.js index d799c194..7f85059b 100644 --- a/test/compress/yields.js +++ b/test/compress/yields.js @@ -644,3 +644,33 @@ issue_4623: { expect_stdout: "PASS" node_version: ">=4" } + +issue_4633: { + options = { + collapse_vars: true, + unused: true, + } + input: { + var a = function*() { + (function(log) { + log(typeof this); + })(yield "PASS"); + }(); + console.log(a.next().value); + a.next(console.log); + } + expect: { + var a = function*() { + (function(log) { + log(typeof this); + })(yield "PASS"); + }(); + console.log(a.next().value); + a.next(console.log); + } + expect_stdout: [ + "PASS", + "object", + ] + node_version: ">=4" +}