fix corner case in ie8 (#4532)

fixes #4531
This commit is contained in:
Alex Lam S.L
2021-01-10 16:01:49 +00:00
committed by GitHub
parent ba54d074d8
commit dbfa5d4d14
2 changed files with 62 additions and 3 deletions

View File

@@ -311,8 +311,9 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
}
if (node instanceof AST_SymbolLambda) {
var def = node.thedef;
redefine(node, node.scope.parent_scope.resolve());
if (typeof node.thedef.init !== "undefined") {
if (!redefine(node, node.scope.parent_scope.resolve())) {
delete def.defun;
} else if (typeof node.thedef.init !== "undefined") {
node.thedef.init = false;
} else if (def.init) {
node.thedef.init = def.init;
@@ -332,7 +333,7 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
var old_def = node.thedef;
if (!all(old_def.orig, function(sym) {
return !(sym instanceof AST_SymbolConst || sym instanceof AST_SymbolLet);
})) return;
})) return false;
var new_def = scope.find_variable(name);
if (new_def) {
var redef = new_def.redefined();
@@ -352,6 +353,7 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
node.reference(options);
});
if (new_def.undeclared) self.variables.set(name, new_def);
return true;
}
});

View File

@@ -1282,3 +1282,60 @@ issue_4438: {
expect_stdout: "PASS"
node_version: ">=4"
}
issue_4531_1: {
mangle = {
ie8: true,
toplevel: true,
}
input: {
"use strict";
var a;
console.log(function a() {
let a;
var b;
}());
}
expect: {
"use strict";
var o;
console.log(function o() {
let o;
var t;
}());
}
expect_stdout: "undefined"
node_version: ">=4"
}
issue_4531_2: {
options = {
evaluate: true,
ie8: true,
toplevel: true,
}
mangle = {
ie8: true,
toplevel: true,
}
input: {
"use strict";
var a = console;
console.log(typeof a, function a() {
let { [console]: a } = 0 && a;
var b = console;
while (!b);
}());
}
expect: {
"use strict";
var o = console;
console.log(typeof o, function o() {
let { [console]: o } = 0;
var e = console;
while (!e);
}());
}
expect_stdout: "object undefined"
node_version: ">=6"
}