fix corner case in merge_vars (#5445)

fixes #5444
This commit is contained in:
Alex Lam S.L
2022-05-16 09:30:14 +01:00
committed by GitHub
parent 3aa92c76cc
commit f70462aeb2
7 changed files with 112 additions and 47 deletions

View File

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

View File

@@ -184,12 +184,12 @@ merge_vars_2: {
expect: {
var a = 0;
1 && --a,
b = function f() {
a = function f() {
const c = a && f;
c.var += 0;
}(),
void console.log(b);
var b;
void console.log(a);
var a;
}
expect_stdout: "undefined"
}

View File

@@ -2239,3 +2239,77 @@ issue_5407: {
]
node_version: ">=6"
}
issue_5444_1: {
options = {
merge_vars: true,
toplevel: true,
}
input: {
var a = 42;
var b = function({} = setImmediate(function() {
console.log(a++);
})) {
return this;
}();
console.log(typeof b);
}
expect: {
var a = 42;
var b = function({} = setImmediate(function() {
console.log(a++);
})) {
return this;
}();
console.log(typeof b);
}
expect_stdout: [
"object",
"42",
]
node_version: ">=6"
}
issue_5444_2: {
options = {
merge_vars: true,
}
input: {
function f(a, b = a++) {
return b;
}
console.log(f("FAIL") || "PASS");
}
expect: {
function f(a, b = a++) {
return b;
}
console.log(f("FAIL") || "PASS");
}
expect_stdout: "PASS"
node_version: ">=6"
}
issue_5444_3: {
options = {
merge_vars: true,
}
input: {
function f(a, b = function(c = a *= this) {
return c;
}()) {
return b;
}
console.log(f("FAIL") || "PASS");
}
expect: {
function f(a, b = function(c = a *= this) {
return c;
}()) {
return b;
}
console.log(f("FAIL") || "PASS");
}
expect_stdout: "PASS"
node_version: ">=6"
}

View File

@@ -1815,8 +1815,8 @@ issue_4288: {
console.log(typeof b);
}()]: a,
}) {
var b = a;
b++;
var a = a;
a++;
}
f(0);
}

View File

@@ -237,12 +237,12 @@ merge_vars_2: {
"use strict";
var a = 0;
1 && --a,
b = function f() {
a = function f() {
let c = a && f;
c.var += 0;
}(),
void console.log(b);
var b;
void console.log(a);
var a;
}
expect_stdout: "undefined"
node_version: ">=4"