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

3038return statement flagged as syntax error

Expand Messages
  • octavpo
    Oct 3, 2012
    • 0 Attachment
      I have a statement in one of my functions:

      return serverInstanceId = response;

      JSLint flags it as:

      Expected ';' and instead saw '='.
      Unreachable '=' after 'return'.
      Expected '=' at column 9, not column 33.
      Expected an identifier and instead saw '='.

      It seems it doesn't accept assignments inside return expressions. However assignments are expressions in JS, so this should be a valid statement. I would agree this might be considered bad style, and it could be flagged as such, but that's another matter. The messages indicate it just doesn't accept it as valid syntax. However if I put the assignment in () the messages are gone. So it seems to me this is a bug in JSLint's grammar.

      Thanks,
      Octav
    • Show all 10 messages in this topic