yoya / js2-mode

Automatically exported from code.google.com/p/js2-mode
0 stars 0 forks source link

ECMAScript-262 5th Edition "use strict"; directive is incorrectly flagged as no-side-effect code #115

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Open a JavaScript file in the js-ide.
2. Type "use strict"; all on its own line.

What Happens: 
The "use strict"; directive is flagged as no-side-effect code, and 
underlined in the js-ide code-warning color.

What is the expected output? What do you see instead?

ECMAScript-262 5th Edition "use strict"; directive should not be 
incorrectly flagged as no-side-effect code (e.g., it should not be 
underlined and seen as suboptimal by the js-ide rules).

What version of the product are you using? On what operating system?

  js2.el Version: 20080616

  GNU Emacs 22.2.1 (i486-pc-linux-gnu, X toolkit, Xaw3d scroll bars) of 
2008-09-05 on vernadsky, modified by Ubuntu

   uname -a
Linux vr2dev02 2.6.28-11-server #42-Ubuntu SMP Fri Apr 17 02:48:10 UTC 2009 
i686 GNU/Linux

Please provide any additional information below.

 Reference: http://www.ecma-international.org/publications/files/ECMA-
ST/ECMA-262.pdf

 From the above specification, note that 'use strict' must appear as a 
single statement only (which js2-mode flags as no-side-effect code):

14.1 Directive Prologues and the Use Strict Directive

A Directive Prologue is the longest sequence of ExpressionStatement 
productions occurring as the initial SourceElement productions of a Program 
or FunctionBody and where each ExpressionStatement in the sequence consists 
entirely of a StringLiteral token followed a semicolon. The semicolon may 
appear explicitly or may be inserted by automatic semicolon insertion. A 
Directive Prologue may be an empty sequence.

A Use Strict Directive is an ExpressionStatement in a Directive Prologue 
whose StringLiteral is either the exact character sequences "use strict" or 
'use strict'. A Use Strict Directive may not contain an EscapeSequence or 
LineContinuation.

A Directive Prologue may contain more than one Use Strict Directive. 
However, an implementation may issue a warning if this occurs.

Thank you.

Original issue reported on code.google.com by christop...@yahoo.com on 19 Jan 2010 at 7:03