Loading ...
Sorry, an error occurred while loading the content.

JSLint on Rhino 1_5R5

Expand Messages
  • tfulcher@btinternet.com
    OK, we use a product which embeds Rhino, version 1_5R5. I was looking at running jslint over the scripts written for this tool, however when I used the
    Message 1 of 2 , Sep 28, 2009
    • 0 Attachment
      OK, we use a product which embeds Rhino, version 1_5R5.

      I was looking at running jslint over the scripts written for this tool, however when I used the jslint.js downloaded from the site I keep getting an error in jslint itself when a problem in a script exists -

      js: "C:\workspace\rhino\jslint.js", line 462: The undefined value has no properties.

      Questions:
      1. Do previous versions of jslint.js exist which may be compatible with that version of Rhino ? If so where can I get them from?

      2. If I utilise a more recent version of Rhino which makes JSLint work, how confident can I be that I'm testing like for like, i.e. sure the script is fine in a newer Rhino but a problem may occur on 1_5R5?

      thanks

      Tim
    • Stefan Weiss
      ... I had a very similar error with JSLint in connection with Rhino. It was no fun debugging it, because the error was triggered right in the middle of
      Message 2 of 2 , Sep 29, 2009
      • 0 Attachment
        On 28/09/09 17:36, tfulcher@... wrote:
        > OK, we use a product which embeds Rhino, version 1_5R5.
        >
        > I was looking at running jslint over the scripts written for this
        > tool, however when I used the jslint.js downloaded from the site I keep
        > getting an error in jslint itself when a problem in a script exists -
        >
        > js: "C:\workspace\rhino\jslint.js", line 462: The undefined value has
        > no properties.

        I had a very similar error with JSLint in connection with Rhino. It was
        no fun debugging it, because the error was triggered right in the middle
        of JSLint's parser part, but I was able to pinpoint it to this passage:

        // line #2368
        if (t.identifier && !t.reserved && peek().id === ':') {

        peek() was returning undefined, and trying to access a property of
        undefined caused the error message "Cannot read property "id" from
        undefined", similar to what you posted.

        Digging further, it turned out that the loop in peek was never entered:

        // line #1851
        function peek(p) {
        var i = p || 0, j = 0, t;

        while (j <= i) {
        t = lookahead[j];
        if (!t) {
        t = lookahead[j] = lex.token();
        }
        j += 1;
        }
        return t;
        }

        This shouldn't be possible, but due to what I suspect is an engine bug
        in the version of Rhino we were using,

        var i = undefined || 0;

        assigns undefined to i, instead of 0, and thus the <= comparison fails.
        JSLint is not to blame here. I've written a class with a few test cases,
        which uncovered more bugs in a similar context [0]. The version of Rhino
        we were using is the one bundled with the Java 6 JDK (1.6.0_10). It
        identifies itself as "Mozilla Rhino, version 1.6 release 2", which is
        more recent than the version you referred to, but still ancient.

        > 2. If I utilise a more recent version of Rhino which makes JSLint
        > work, how confident can I be that I'm testing like for like, i.e. sure
        > the script is fine in a newer Rhino but a problem may occur on 1_5R5?

        I've successfully used JSLint with Rhino versions 1.6R7 and upwards, so
        I think you should be fine. From what I've seen, the standalone Rhino
        version also performs better than the bundled engine.


        cheers,
        stefan


        [0] http://preview.tinyurl.com/ydj7ps3


        --
        LOAD"Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn!",8,1
        RUN!
      Your message has been successfully submitted and would be delivered to recipients shortly.