Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

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

     
  • Good catch! Fixed in r315.