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

var x=foo.if (a>b) -bar;

Expand Messages
  • Douglas Crockford
    TC39 is currently discussing this problem: Suppose you mistype ; as . . var x=foo. if (a b) -bar; It will be read as var x = foo.if(a b) - bar; ES3 will
    Message 1 of 1 , Aug 25, 2010
    • 0 Attachment
      TC39 is currently discussing this problem: Suppose you mistype ';' as '.'.

      var x=foo.
      if (a>b) -bar;

      It will be read as

      var x = foo.if(a > b) - bar;

      ES3 will barf on 'if' as a reserved word violation. ES5 accepts the statement. This is an argument going on that a line break should not be allowed after '.'.

      Should JSLint adopt that rule? (Currently, JSLint allows a break after '.'.)

      Also notice that if it had been written as

      var x=foo.
      if (a>b) {
      -bar;
      }

      then JSLint will give a warning now. Also, if the '.' is corrected to ';', then JSLint provides warnings, so it is already unlikely that a JSLint user will be snagged by this.

      One concern I have about the new syntax being proposed for future editions, is that source code redundancy is being lost, which can frustrate error detection.
    Your message has been successfully submitted and would be delivered to recipients shortly.