checkpoint

This commit is contained in:
Mihai Bazon
2012-09-04 15:36:14 +03:00
parent 376667a818
commit 1b5183dd5e
4 changed files with 45 additions and 10 deletions

View File

@@ -165,6 +165,7 @@ AST_Toplevel.DEFMETHOD("scope_warnings", function(options){
unreferenced : true,
assign_to_global : true,
func_arguments : true,
nested_defuns : true,
eval : true
});
var tw = new TreeWalker(function(node){
@@ -225,6 +226,17 @@ AST_Toplevel.DEFMETHOD("scope_warnings", function(options){
col: node.start.col
});
}
if (options.nested_defuns
&& node instanceof AST_Defun
&& !(tw.parent() instanceof AST_Scope
|| (tw.parent() instanceof AST_BlockStatement
&& tw.parent(1) instanceof AST_Scope))) {
AST_Node.warn("Function {name} declared in nested statement [{line},{col}]", {
name: node.name.name,
line: node.start.line,
col: node.start.col
});
}
});
this.walk(tw);
});