This was causing javascriptlint to crash:
var foo = 1; var bar = 2;
alert(foo == foo == 3);
This fixes it:
-- javascriptlint/warnings.py (revision 303) +++ javascriptlint/warnings.py (working copy) @@ -269,9 +269,16 @@
@lookfor(tok.EQOP,tok.RELOP) def useless_comparison(node): - lvalue, rvalue = node.kids - if lvalue.is_equivalent(rvalue): - raise LintWarning, node + if (len(node.kids) > 2): + for i in range(0,len(node.kids)-1): + lvalue = node.kids_ + rvalue = node.kids + if lvalue.is_equivalent(rvalue): + raise LintWarning, node + else: + lvalue, rvalue = node.kids + if lvalue.is_equivalent(rvalue): + raise LintWarning, node
@lookfor((tok.COLON, op.NAME)) def use_of_label(node):_
Good catch! Fixed in r315.
Log in to post a comment.
This was causing javascriptlint to crash:
var foo = 1;
var bar = 2;
alert(foo == foo == 3);
This fixes it:
Index: javascriptlint/warnings.py
-- javascriptlint/warnings.py (revision 303)
+++ javascriptlint/warnings.py (working copy)
@@ -269,9 +269,16 @@
@lookfor(tok.EQOP,tok.RELOP)
def useless_comparison(node):
- lvalue, rvalue = node.kids
- if lvalue.is_equivalent(rvalue):
- raise LintWarning, node
+ if (len(node.kids) > 2):
+ for i in range(0,len(node.kids)-1):
+ lvalue = node.kids_
+ rvalue = node.kids
+ if lvalue.is_equivalent(rvalue):
+ raise LintWarning, node
+ else:
+ lvalue, rvalue = node.kids
+ if lvalue.is_equivalent(rvalue):
+ raise LintWarning, node
@lookfor((tok.COLON, op.NAME))
def use_of_label(node):_
Good catch! Fixed in r315.