fix corner case in merge_vars (#5472)

fixes #5471
This commit is contained in:
Alex Lam S.L
2022-05-26 20:13:24 +01:00
committed by GitHub
parent 0dbf2b1d3c
commit 94aae05d45
5 changed files with 102 additions and 18 deletions

View File

@@ -726,8 +726,8 @@ issue_4401: {
expect: {
(function() {
var a = (b => b(a))(console.log || a);
var a = console.log;
a && a(typeof b);
var c = console.log;
c && c(typeof b);
})();
}
expect_stdout: [

View File

@@ -2986,15 +2986,15 @@ issue_5456: {
var a = true;
(function() {
b = (i = a, console.log("foo") && i),
i = async function() {
d = async function() {
c = await null;
}(),
e = function() {
if (c) console.log(typeof i);
if (c) console.log(typeof d);
while (b);
}(),
void 0;
var b, c, i, e;
var b, c, d, e;
var i;
})();
}

View File

@@ -3754,3 +3754,94 @@ issue_5451: {
}
expect_stdout: "0"
}
issue_5471_1: {
options = {
conditionals: true,
inline: true,
merge_vars: true,
reduce_vars: true,
sequences: true,
side_effects: true,
toplevel: true,
unused: true,
}
input: {
var a = "FAIL 1";
function f(b, c) {
function g() {
if (console)
return 42;
else
c = "FAIL 2";
}
var d = g();
console.log(c || "PASS");
var e = function h() {
while (b && e);
}();
}
f(a++) && a;
}
expect: {
var a = "FAIL 1";
var b, c, e;
b = +a,
function() {
if (console)
return;
c = "FAIL 2";
}(),
console.log(c || "PASS"),
e = function() {
while (b && e);
}();
}
expect_stdout: "PASS"
}
issue_5471_2: {
options = {
conditionals: true,
evaluate: true,
inline: true,
merge_vars: true,
reduce_vars: true,
sequences: true,
toplevel: true,
unused: true,
}
input: {
var a = "FAIL 1";
function f(b, c) {
function g() {
if (console)
return 42;
else
c = "FAIL 2";
}
var d = g();
console.log(c || "PASS");
var e = function h() {
while (b && e);
}();
}
f(a++) && a;
}
expect: {
var a = "FAIL 1";
var b, c, e;
b = +a,
function() {
if (console)
return;
c = "FAIL 2";
}(),
console.log(c || "PASS"),
e = function() {
while (b && e);
}(),
void 0;
}
expect_stdout: "PASS"
}

View File

@@ -1574,15 +1574,15 @@ issue_5456: {
var a = true;
(function() {
b = (i = a, console.log("foo") && i),
i = function*() {
d = function*() {
c = null;
}(),
e = function() {
if (c) console.log(typeof i);
if (c) console.log(typeof d);
while (b);
}(),
void 0;
var b, c, i, e;
var b, c, d, e;
var i;
})();
}