fix corner cases in rename & varify (#4955)

fixes #4954
This commit is contained in:
Alex Lam S.L
2021-05-23 23:54:48 +01:00
committed by GitHub
parent 5d4e6e3bdc
commit 8b0c836515
5 changed files with 118 additions and 12 deletions

View File

@@ -1535,3 +1535,56 @@ issue_4848: {
}
expect_stdout: "PASS"
}
issue_4954_1: {
rename = true
input: {
(function() {
{
const a = "foo";
console.log(a);
}
{
const a = "bar";
console.log(a);
}
})();
}
expect: {
(function() {
{
const a = "foo";
console.log(a);
}
{
const a = "bar";
console.log(a);
}
})();
}
expect_stdout: true
}
issue_4954_2: {
mangle = {}
input: {
"use strict";
const a = null;
(function(b) {
for (const a in null);
for (const a in b)
console.log("PASS");
})([ null ]);
}
expect: {
"use strict";
const a = null;
(function(o) {
for (const n in null);
for (const n in o)
console.log("PASS");
})([ null ]);
}
expect_stdout: "PASS"
node_version: ">=4"
}

View File

@@ -3080,11 +3080,9 @@ issue_4235: {
})();
}
expect: {
(function() {
f = console.log(f),
void 0;
var f;
})();
void function() {
var f = console.log(f);
}();
}
expect_stdout: "undefined"
}

View File

@@ -575,3 +575,41 @@ issue_4933_2: {
}
expect_stdout: "undefined"
}
issue_4954: {
options = {
functions: true,
reduce_vars: true,
unused: true,
varify: true,
}
input: {
"use strict";
(function() {
{
let a = console;
console.log(typeof a);
}
{
let a = function() {};
a && console.log(typeof a);
}
})();
}
expect: {
"use strict";
(function() {
var a = console;
console.log(typeof a);
{
let a = function() {};
a && console.log(typeof a);
}
})();
}
expect_stdout: [
"object",
"function",
]
node_version: ">=4"
}