Hopefully last word on Use Strict Directive syntax

David-Sarah Hopwood david-sarah at jacaranda.org
Tue Jun 9 16:39:32 PDT 2009

Allen Wirfs-Brock wrote:
>> -----Original Message-----
>> From: es5-discuss-bounces at mozilla.org [mailto:es5-discuss-
>> bounces at mozilla.org] On Behalf Of David-Sarah Hopwood
> ...
>>>> If you get into the habit of
>>>> omitting semicolons, you can also run into trouble with things that
>>>> look like they're strict but are not:
>>>> function f(x) {
>>>>  "use strict"
>>>>  +x ? delete p : delete q;
>>>> }
>> This hazard, OTOH, can't be fixed, because the "use strict" is not a
>> directive in this case, and you would have to know that it is a
>> directive before you could require a semicolon after it.
> This seems like a strong argument for not trying to forbid semicolon
> insertion in the Directive Prologue. 

Well, it is an argument for not making the directive prologue a special
case. (I have previously argued for strict mode to forbid syntactic
semicolon semicolon insertion entirely, but Brendan was opposed, and
that argument has been lost for ES5.)

A linter could use the heuristic that the '+' is not indented relative
to the '"' to infer that a semicolon was probably intended.

David-Sarah Hopwood  ⚥  http://davidsarah.livejournal.com

More information about the es5-discuss mailing list