2008/9/4 Michael Daumling <[EMAIL PROTECTED]>:
> The following code produces a "first is not a function" error:
>
>
>
> Array.prototype.first = function()
>
> { return this.length == 0 ? null : this[0]; }
>
> // no semicolon here
>
> (function() { if ([1,2].first() == 1) alert ("OK"); }())
That's a quite well defined part of automatic semicolon insertion. I
don't think it's possible to do anything about it for general script.
In a stricter syntax mode or with an external opt-in, one could
possibly turn off automatic semicolon insertion except for when
semicolons are redundant (such as before closing curlies).
> IMHO, there should be a rule that if a function-expression is followed by
> anything with brackets (), it would require the function-expression to be
> bracketed as well, otherwise, the bracketed statement does not become part
> of the assignment.
Not only is that a radical complexification of the automatic semicolon
insertion mechanism, it's also an incompatible one.
> Can/should this be fixed for 3.1?
Doesn't sound like something for 3.1, and I wouldn't want to see it in Harmony.
--
David "liorean" Andersson
_______________________________________________
Es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss