Show Script Warnings for ASI at EOF




JavaScript Engine
7 years ago
3 years ago


(Reporter: Garrett Smith, Unassigned)


Firefox Tracking Flags

(Not tracked)




7 years ago
Automatic Semicolon Insertion causes problems when Program, then a semicolon is automatically inserted at the end of the input stream.  

Productions that are not restricted can be created accidentally where ASI has been used. This is often the result of where the developer forgot to use a semicolon. Regardless, the problems it creates can occur when the order of Statements changes or when line terminators are added or removed, including those that appear in comments. Where semicolons are needed, it is recommended that they appear explicitly. 

So, for starters, warn against ASI at the end of a file. This won't correct for mistakes where order of statements is rearranged; only when files are concatenated. 

For example, file a.js:

| var MyWidget = function(){
| = "mike";
| }

ASI occurs at the end of the file. A warning should be issued in that case (at least, for starters).
Without a semicolon ending the function assignment errors can result when b.js is appended to a.js (b.js could contain any valid js). A warning would help prevent these errors.
I'm confused why this would be something we should warn against in the browser. Isn't this only a hazard in offline build processes based on script concatenation? If a page contains multiple <script> tags, it's not going to treat them as one concatenated Program production, right?

Also, should this be filed under Core|JavaScript Engine instead?


Comment 3

7 years ago
Warning in the browser for ASI could help find a missing semicolong when developers develop a script tag independently. When that script is then build to a concatenated script, there's no changed behavior.
Assignee: nobody → general
Component: Interpreter → JavaScript Engine
Product: Tamarin → Core
QA Contact: interpreter → general


3 years ago
Assignee: general → nobody
You need to log in before you can comment on or make changes to this bug.