fix corner cases in typeofs (#5286)
This commit is contained in:
@@ -8764,14 +8764,40 @@ Compressor.prototype.compress = function(node) {
|
||||
return;
|
||||
}
|
||||
if (!body) return;
|
||||
var abort = false;
|
||||
var def = sym.definition();
|
||||
var tw = new TreeWalker(function(node) {
|
||||
if (node instanceof AST_Scope) {
|
||||
var parent = tw.parent();
|
||||
if (parent instanceof AST_Call && parent.expression === node) return;
|
||||
var fn;
|
||||
var tw = new TreeWalker(function(node, descend) {
|
||||
if (abort) return true;
|
||||
if (node instanceof AST_Assign) {
|
||||
var ref = node.left;
|
||||
if (!(ref instanceof AST_SymbolRef && ref.definition() === def)) return;
|
||||
node.right.walk(tw);
|
||||
switch (node.operator) {
|
||||
case "=":
|
||||
case "&&=":
|
||||
abort = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (node instanceof AST_Call) {
|
||||
descend();
|
||||
fn = node.expression.tail_node();
|
||||
if (fn instanceof AST_Lambda) {
|
||||
fn.walk(tw);
|
||||
} else {
|
||||
abort = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (node instanceof AST_Scope) {
|
||||
if (node === fn) return;
|
||||
return true;
|
||||
}
|
||||
if (node instanceof AST_SymbolRef) {
|
||||
if (node.definition() === def) node.defined = true;
|
||||
return true;
|
||||
}
|
||||
if (node instanceof AST_SymbolRef && node.definition() === def) node.defined = true;
|
||||
});
|
||||
body.walk(tw);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user