From 1a064b6e741f9c3e98f4e2de8084c48f324c0318 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Thu, 24 Jun 2021 12:43:46 +0100 Subject: fix corner case in `functions` (#5035) fixes #5034 --- test/compress/awaits.js | 34 ++++++++++++++++++++++++++++++++++ test/compress/yields.js | 30 ++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) (limited to 'test') diff --git a/test/compress/awaits.js b/test/compress/awaits.js index a0d744ba..eb808464 100644 --- a/test/compress/awaits.js +++ b/test/compress/awaits.js @@ -1989,3 +1989,37 @@ issue_5032_webkit: { ] node_version: ">=8" } + +issue_5034: { + options = { + functions: true, + reduce_vars: true, + unused: true, + } + input: { + (function() { + var await = function f() { + return async function() { + return f; + }; + }; + await()().then(function(value) { + console.log(value === await ? "PASS" : "FAIL"); + }); + })(); + } + expect: { + (function() { + var await = function f() { + return async function() { + return f; + }; + }; + await()().then(function(value) { + console.log(value === await ? "PASS" : "FAIL"); + }); + })(); + } + expect_stdout: "PASS" + node_version: ">=8" +} diff --git a/test/compress/yields.js b/test/compress/yields.js index 5761d85e..9df533b9 100644 --- a/test/compress/yields.js +++ b/test/compress/yields.js @@ -1216,3 +1216,33 @@ issue_5032_webkit: { ] node_version: ">=4" } + +issue_5034: { + options = { + functions: true, + reduce_vars: true, + unused: true, + } + input: { + console.log(function() { + var yield = function f() { + return function*() { + return f; + }; + }; + return yield()().next().value === yield; + }() ? "PASS" : "FAIL"); + } + expect: { + console.log(function() { + var yield = function f() { + return function*() { + return f; + }; + }; + return yield()().next().value === yield; + }() ? "PASS" : "FAIL"); + } + expect_stdout: "PASS" + node_version: ">=4" +} -- cgit v1.2.3