diff options
author | Mihai Bazon <mihai@bazon.net> | 2012-09-04 15:36:14 +0300 |
---|---|---|
committer | Mihai Bazon <mihai@bazon.net> | 2012-09-04 15:36:14 +0300 |
commit | 1b5183dd5ee7d2b147f5862c9abf8f45f50fc82f (patch) | |
tree | a75e738de8b3c54a518fad369a2f480d858e94ff /lib/scope.js | |
parent | 376667a8188083e4e64ef56bf10f38e4f831447f (diff) | |
download | tracifyjs-1b5183dd5ee7d2b147f5862c9abf8f45f50fc82f.tar.gz tracifyjs-1b5183dd5ee7d2b147f5862c9abf8f45f50fc82f.zip |
checkpoint
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); }); |