diff options
Diffstat (limited to 'lib/scope.js')
-rw-r--r-- | lib/scope.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/scope.js b/lib/scope.js index 9c2f8530..0f9969d2 100644 --- a/lib/scope.js +++ b/lib/scope.js @@ -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); }); |