[javascriptlint-commit] SF.net SVN: javascriptlint:[323] trunk
Status: Beta
Brought to you by:
matthiasmiller
From: <mat...@us...> - 2013-09-30 23:16:40
|
Revision: 323 http://sourceforge.net/p/javascriptlint/code/323 Author: matthiasmiller Date: 2013-09-30 23:16:37 +0000 (Mon, 30 Sep 2013) Log Message: ----------- Function expressions should not declare a variable. Modified Paths: -------------- trunk/javascriptlint/lint.py trunk/jsengine/parser/__init__.py trunk/tests/control_comments/option_explicit.js Modified: trunk/javascriptlint/lint.py =================================================================== --- trunk/javascriptlint/lint.py 2013-09-30 21:54:32 UTC (rev 322) +++ trunk/javascriptlint/lint.py 2013-09-30 23:16:37 UTC (rev 323) @@ -609,7 +609,7 @@ @visitation.visit('push', tok.FUNCTION) def _push_func(self, node): - if node.fn_name: + if node.opcode != 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/jsengine/parser/__init__.py =================================================================== --- trunk/jsengine/parser/__init__.py 2013-09-30 21:54:32 UTC (rev 322) +++ trunk/jsengine/parser/__init__.py 2013-09-30 23:16:37 UTC (rev 323) @@ -162,10 +162,8 @@ fn_body_endpos = t.expect(tok.RBRACE).endpos fn_body = ParseNode(kind.LC, None, fn_body_startpos, fn_body_endpos, None, kids) - return ParseNode(kind.FUNCTION, - op.ANONFUNOBJ if fn_name is None else op.NAMEDFUNOBJ, - startpos, fn_body.endpos, - fn_name, [fn_body], fn_args=fn_args) + return ParseNode(kind.FUNCTION, opcode, startpos, fn_body.endpos, + fn_name, [fn_body], fn_args=fn_args) def _argument_list(t): args = [] Modified: trunk/tests/control_comments/option_explicit.js =================================================================== --- trunk/tests/control_comments/option_explicit.js 2013-09-30 21:54:32 UTC (rev 322) +++ trunk/tests/control_comments/option_explicit.js 2013-09-30 23:16:37 UTC (rev 323) @@ -60,5 +60,12 @@ /* illegal */ y(); /*warning:undeclared_identifier*/ + // This should be undeclared because this is an expression, + // not a declaration. + (function func_expr() { /*warning:want_assign_or_call*/ + return 10; + }); + j = func_expr(); + return ""; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |