[javascriptlint-commit] SF.net SVN: javascriptlint: [175] trunk
Status: Beta
Brought to you by:
matthiasmiller
|
From: <mat...@us...> - 2008-03-20 21:31:09
|
Revision: 175
http://javascriptlint.svn.sourceforge.net/javascriptlint/?rev=175&view=rev
Author: matthiasmiller
Date: 2008-03-20 14:31:06 -0700 (Thu, 20 Mar 2008)
Log Message:
-----------
missing_break warning: fix try/catch/finally statements
Modified Paths:
--------------
trunk/pyjsl/warnings.py
trunk/tests/warnings/missing_break.js
Modified: trunk/pyjsl/warnings.py
===================================================================
--- trunk/pyjsl/warnings.py 2008-03-20 21:30:17 UTC (rev 174)
+++ trunk/pyjsl/warnings.py 2008-03-20 21:31:06 UTC (rev 175)
@@ -89,12 +89,28 @@
elif node.kind == tok.TRY:
try_, catch_, finally_ = node.kids
+ assert catch_.kind == tok.RESERVED
+ catch_, = catch_.kids
+ assert catch_.kind == tok.LEXICALSCOPE
+ catch_, = catch_.kids
+ assert catch_.kind == tok.CATCH
+ ignored, ignored, catch_ = catch_.kids
+ assert catch_.kind == tok.LC
+
exit_points = _get_exit_points(try_) | _get_exit_points(catch_)
if finally_:
- # Always if the finally has an exit point
- if None in exit_points:
- exit_points.remove(None)
- exit_points |= _get_exit_points(finally_)
+ finally_exit_points = _get_exit_points(finally_)
+ if None in finally_exit_points:
+ # The finally statement does not add a missing exit point.
+ finally_exit_points.remove(None)
+ else:
+ # If the finally statement always returns, the other
+ # exit points are irrelevant.
+ if None in exit_points:
+ exit_points.remove(None)
+
+ exit_points |= finally_exit_points
+
else:
exit_points = set([None])
@@ -311,7 +327,8 @@
if not case_contents.kids:
return
if None in _get_exit_points(case_contents):
- return node
+ # Show the warning on the *next* node.
+ return node.parent.kids[node.node_index+1]
class missing_break_for_last_case:
'missing break statement for last case in switch'
Modified: trunk/tests/warnings/missing_break.js
===================================================================
--- trunk/tests/warnings/missing_break.js 2008-03-20 21:30:17 UTC (rev 174)
+++ trunk/tests/warnings/missing_break.js 2008-03-20 21:31:06 UTC (rev 175)
@@ -52,7 +52,7 @@
}
case 6: /*warning:missing_break*/
- /*ok; finally statement never called*/
+ /*ok; finally statement does not affect it */
try {
i--;
break;
@@ -79,6 +79,19 @@
break;
}
+ case 8:
+ /*ok; return statement in finally*/
+ try {
+ i--;
+ }
+ catch (err) {
+ s = null;
+ }
+ finally {
+ i++;
+ return i;
+ }
+
default:
break;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|