[javascriptlint-commit] SF.net SVN: javascriptlint:[324] trunk
Status: Beta
Brought to you by:
matthiasmiller
From: <mat...@us...> - 2013-10-01 17:07:15
|
Revision: 324 http://sourceforge.net/p/javascriptlint/code/324 Author: matthiasmiller Date: 2013-10-01 17:07:11 +0000 (Tue, 01 Oct 2013) Log Message: ----------- Correctly handle top-level function declarations. Modified Paths: -------------- trunk/javascriptlint/lint.py trunk/tests/control_comments/option_explicit.js trunk/tests/warnings/redeclared_var.js trunk/tests/warnings/unreferenced_identifier.js Modified: trunk/javascriptlint/lint.py =================================================================== --- trunk/javascriptlint/lint.py 2013-09-30 23:16:37 UTC (rev 323) +++ trunk/javascriptlint/lint.py 2013-10-01 17:07:11 UTC (rev 324) @@ -609,7 +609,7 @@ @visitation.visit('push', tok.FUNCTION) def _push_func(self, node): - if node.opcode != op.CLOSURE and node.fn_name: + if node.opcode in (None, op.CLOSURE) and node.fn_name: _warn_or_declare(scopes[-1], node.fn_name, 'function', node, report) self._push_scope(node) for var_name in node.fn_args: Modified: trunk/tests/control_comments/option_explicit.js =================================================================== --- trunk/tests/control_comments/option_explicit.js 2013-09-30 23:16:37 UTC (rev 323) +++ trunk/tests/control_comments/option_explicit.js 2013-10-01 17:07:11 UTC (rev 324) @@ -65,7 +65,10 @@ (function func_expr() { /*warning:want_assign_or_call*/ return 10; }); - j = func_expr(); + j = func_expr(); /*warning:undeclared_identifier*/ return ""; } + +// Ensure that we can reference top-level functions. +option_explicit(null); Modified: trunk/tests/warnings/redeclared_var.js =================================================================== --- trunk/tests/warnings/redeclared_var.js 2013-09-30 23:16:37 UTC (rev 323) +++ trunk/tests/warnings/redeclared_var.js 2013-10-01 17:07:11 UTC (rev 324) @@ -7,4 +7,9 @@ return; } var myFunction; /*warning:redeclared_var*/ + + // myFunction isn't a redeclaration, since function names in function + // expressions don't matter. + var tmp = function myFunction(){}; + /*jsl:unused tmp*/ } Modified: trunk/tests/warnings/unreferenced_identifier.js =================================================================== --- trunk/tests/warnings/unreferenced_identifier.js 2013-09-30 23:16:37 UTC (rev 323) +++ trunk/tests/warnings/unreferenced_identifier.js 2013-10-01 17:07:11 UTC (rev 324) @@ -74,8 +74,10 @@ tmp = ref_dec--; /*warning:inc_dec_within_stmt*/ tmp = -tmp; - /* Test named functions as references. */ - var fn = function ref_func() { return 42; }; /*warning:unreferenced_function*/ + /* Test named functions as references. + * (The name is ignored since it's a function expression.) + */ + var fn = function ref_func() { return 42; }; fn(); /* Test nested scopes. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |