Menu

Fix for crash on "foo == bar == fo...

Jon Snell
2013-05-08
2013-09-28
  • Jon Snell

    Jon Snell - 2013-05-08

    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):_

     
  • Matthias Miller

    Matthias Miller - 2013-09-28

    Good catch! Fixed in r315.

     

Log in to post a comment.