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

"Stopping, unable to continue" errors on mulitple variable assigment

Expand Messages
  • kevin_hakanson
    I was code reviewing some code, which is similar to the structure below: var x = { y : not test }; var z = x.y = test ; It gets several errors, and the
    Message 1 of 3 , Apr 27, 2009
    • 0 Attachment
      I was code reviewing some code, which is similar to the structure below:

      var x = { "y" : "not test"};
      var z = x.y = "test";

      It gets several errors, and the scanning stops.

      Error:
      Problem at line 2 character 12: Missing semicolon.
      var z = x.y = "test";
      Problem at line 2 character 13: Expected an identifier and instead saw '='.
      var z = x.y = "test";
      Problem at line 2 character 13: Stopping, unable to continue. (50% scanned).


      Since I couldn't remember if it should work, I ran these QUnit tests in IE7, FF3 and Chrome - which all passed. Even though it is bad style, should this error cause the jslint scanner to stop?

      test("z = 'test'", function() {
      equals("test", z);
      });
      test("x.y = 'test'", function() {
      equals("test", x.y);
      });
    • Douglas Crockford
      ... JSLint will now accept var z = x.y = test ; It will continue to reject var z = x = test ; because a common error is to think that it means the same thing
      Message 2 of 3 , Apr 27, 2009
      • 0 Attachment
        --- In jslint_com@yahoogroups.com, "kevin_hakanson" <kevin.hakanson@...> wrote:
        >
        > I was code reviewing some code, which is similar to the structure below:
        >
        > var x = { "y" : "not test"};
        > var z = x.y = "test";

        JSLint will now accept

        var z = x.y = "test";

        It will continue to reject

        var z = x = "test";

        because a common error is to think that it means the same thing as

        var z = "test", x = "test";
      • Stepan Reznikov
        ... Maybe JSLint should reject it only when the x variable has not been declared before?
        Message 3 of 3 , Apr 28, 2009
        • 0 Attachment
          > It will continue to reject
          > var z = x = "test";

          Maybe JSLint should reject it only when the x variable has not been
          declared before?
        Your message has been successfully submitted and would be delivered to recipients shortly.