fix corner case in merge_vars (#4113)

fixes #4112
This commit is contained in:
Alex Lam S.L
2020-09-16 15:18:28 +01:00
committed by GitHub
parent 2039185051
commit 219aac6a84
2 changed files with 42 additions and 3 deletions

View File

@@ -4468,20 +4468,23 @@ merge(Compressor.prototype, {
skipped.unshift(tail);
continue;
}
var orig = [], refs = [];
if (id in declarations) declarations[id].forEach(function(sym) {
sym.thedef = def;
sym.name = def.name;
def.orig.push(sym);
orig.push(sym);
});
references[id].forEach(function(sym) {
sym.thedef = def;
sym.name = def.name;
if (sym instanceof AST_SymbolRef) {
def.references.push(sym);
refs.push(sym);
} else {
def.orig.push(sym);
orig.push(sym);
}
});
def.orig = orig.concat(def.orig);
def.references = refs.concat(def.references);
def.fixed = tail.definition.fixed && def.fixed;
merged[id] = def;
break;