cleaned up some mess and started the actual compressor
This commit is contained in:
29
lib/scope.js
29
lib/scope.js
@@ -138,19 +138,24 @@ AST_Toplevel.DEFMETHOD("scope_warnings", function(options){
|
||||
col: node.start.col
|
||||
});
|
||||
}
|
||||
if (options.assign_to_global
|
||||
&& node instanceof AST_Assign
|
||||
&& node.left instanceof AST_SymbolRef
|
||||
&& (node.left.undeclared
|
||||
|| (node.left.symbol.global
|
||||
&& node.left.scope !== node.left.symbol.scope)))
|
||||
if (options.assign_to_global)
|
||||
{
|
||||
AST_Node.warn("{msg}: {name} [{line},{col}]", {
|
||||
msg: node.left.undeclared ? "Accidental global?" : "Assignment to global",
|
||||
name: node.left.name,
|
||||
line: node.start.line,
|
||||
col: node.start.col
|
||||
});
|
||||
var sym = null;
|
||||
if (node instanceof AST_Assign && node.left instanceof AST_SymbolRef)
|
||||
sym = node.left;
|
||||
else if (node instanceof AST_ForIn && node.init instanceof AST_SymbolRef)
|
||||
sym = node.init;
|
||||
if (sym
|
||||
&& (sym.undeclared
|
||||
|| (sym.symbol.global
|
||||
&& sym.scope !== sym.symbol.scope))) {
|
||||
AST_Node.warn("{msg}: {name} [{line},{col}]", {
|
||||
msg: sym.undeclared ? "Accidental global?" : "Assignment to global",
|
||||
name: sym.name,
|
||||
line: sym.start.line,
|
||||
col: sym.start.col
|
||||
});
|
||||
}
|
||||
}
|
||||
if (options.eval
|
||||
&& node instanceof AST_SymbolRef
|
||||
|
||||
Reference in New Issue
Block a user