var a = this.a  //!!!! here no semicolon will be auto inserted
[1,2,3].forEach(function(){
   // do something
})

Consider

   arr.map(function(..){..}) // no semicolon wanted here
       [..]

(function(){
    //do something
})()  //!!!! here no semicolon will be auto inserted
(function(){
    //do something else
})()

Consider

curried_async_function(..first argument set..) // no semicolon wanted here
       (function(result){..}) // callback argument

Unfortunately, while ASI creates obvious problems, those do
not seem to have obvious solutions. Not to mention that any
actual changes to ASI might break existing code.

My own favourite approach would link ASI to layout/indentation,
and introduce warnings instead of breaking code:

1 if ASI kicks in, but indentation suggests statement continuation,
   issue a warning
2 if ASI does not kick in, but indentation suggests new statement,
   issue a warning

Item 2 would cover your examples, without breaking mine,
while item 1 would cover another popular ASI trap:

   return // no semicolon intended here
       {..}

while still allowing for

   return    // semicolon intended here
   dead_code()

Claus


_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to