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

Missing semicolon

Expand Messages
  • ps_praveenkr
    Hi, function myFunc() { var v1 = { option: true }; var v2 = v1.option = false; }; JSLint throws the following error messages for the above code snippet: Error:
    Message 1 of 5 , May 30, 2008
    • 0 Attachment
      Hi,

      function myFunc() {
        var v1 = { option: true };
        var v2 = v1.option = false;
      };

      JSLint throws the following error messages for the above code snippet:

      Error:

      Problem at line 3 character 21: Missing semicolon.

      var v2 = v1.option = false;

      Problem at line 3 character 22: Expected an identifier and instead saw '='.

      var v2 = v1.option = false;

      Problem at line 3 character 22: Stopping, unable to continue. (50% scanned).

      Thanks,
      Praveen
    • Douglas Crockford
      ... You are using an assignment expression in a confusing context. Wrap it in parens to show that you are doing it intentionally. function myFunc() { var v1 =
      Message 2 of 5 , May 30, 2008
      • 0 Attachment
        --- In jslint_com@yahoogroups.com, "ps_praveenkr" <ps.praveenkr@...>
        wrote:
        >
        > Hi,
        >
        > function myFunc() {
        > var v1 = { option: true };
        > var v2 = v1.option = false;
        > };
        >
        > JSLint throws the following error messages for the above code snippet:
        >
        > Error:
        >
        > Problem at line 3 character 21: Missing semicolon.
        >
        > var v2 = v1.option = false;
        >
        > Problem at line 3 character 22: Expected an identifier and instead saw
        > '='.
        >
        > var v2 = v1.option = false;
        >
        > Problem at line 3 character 22: Stopping, unable to continue. (50%
        > scanned).

        You are using an assignment expression in a confusing context. Wrap it
        in parens to show that you are doing it intentionally.

        function myFunc() {
        var v1 = { option: true };
        var v2 = (v1.option = false);
        }
      • ps_praveenkr
        I tried that but now I get: Error: Problem at line 3 character 10: Parens are not needed here. var v2 = (v1.option = false); I can ignore this message but my
        Message 3 of 5 , May 30, 2008
        • 0 Attachment
          I tried that but now I get:
          Error:

          Problem at line 3 character 10: Parens are not needed here.

          var v2 = (v1.option = false);
          I can ignore this message but my build system is configured such that it halts when JSLint returns *errors*.



          --- In jslint_com@yahoogroups.com, "Douglas Crockford" <douglas@...> wrote:
          >
          > --- In jslint_com@yahoogroups.com, "ps_praveenkr" ps.praveenkr@
          > wrote:
          > >
          > > Hi,
          > >
          > > function myFunc() {
          > > var v1 = { option: true };
          > > var v2 = v1.option = false;
          > > };
          > >
          > > JSLint throws the following error messages for the above code snippet:
          > >
          > > Error:
          > >
          > > Problem at line 3 character 21: Missing semicolon.
          > >
          > > var v2 = v1.option = false;
          > >
          > > Problem at line 3 character 22: Expected an identifier and instead saw
          > > '='.
          > >
          > > var v2 = v1.option = false;
          > >
          > > Problem at line 3 character 22: Stopping, unable to continue. (50%
          > > scanned).
          >
          > You are using an assignment expression in a confusing context. Wrap it
          > in parens to show that you are doing it intentionally.
          >
          > function myFunc() {
          > var v1 = { option: true };
          > var v2 = (v1.option = false);
          > }
          >
        • Douglas Crockford
          ... JSLint was in error. Please try it now.
          Message 4 of 5 , May 30, 2008
          • 0 Attachment
            --- In jslint_com@yahoogroups.com, "ps_praveenkr" <ps.praveenkr@...>
            wrote:
            >
            > I tried that but now I get:
            > Error:
            >
            > Problem at line 3 character 10: Parens are not needed here.
            >
            > var v2 = (v1.option = false);

            JSLint was in error. Please try it now.
          • ps_praveenkr
            ... That works. Thanks!
            Message 5 of 5 , May 30, 2008
            • 0 Attachment
              --- In jslint_com@yahoogroups.com, "Douglas Crockford" <douglas@...>
              wrote:
              >
              > --- In jslint_com@yahoogroups.com, "ps_praveenkr" <ps.praveenkr@>
              > wrote:
              > >
              > > I tried that but now I get:
              > > Error:
              > >
              > > Problem at line 3 character 10: Parens are not needed here.
              > >
              > > var v2 = (v1.option = false);
              >
              > JSLint was in error. Please try it now.
              >

              That works. Thanks!
            Your message has been successfully submitted and would be delivered to recipients shortly.