fix corner case in ie8 & mangle (#3524)

fixes #3523
This commit is contained in:
Alex Lam S.L
2019-10-24 23:43:19 +08:00
committed by GitHub
parent 0f7aa41e33
commit 82b3eed5ef
2 changed files with 387 additions and 1 deletions

View File

@@ -214,7 +214,13 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
function redefine(node, scope) {
var name = node.name;
var old_def = node.thedef;
var new_def = scope.find_variable(name) || self.globals.get(name) || scope.def_variable(node);
var new_def = scope.find_variable(name);
if (new_def) {
var redef;
while (redef = new_def.redefined()) new_def = redef;
} else {
new_def = self.globals.get(name) || scope.def_variable(node);
}
old_def.orig.concat(old_def.references).forEach(function(node) {
node.thedef = new_def;
node.reference(options);