Open Bug 651346 Opened 13 years ago Updated 2 years ago

Show Script Warnings for ASI at EOF

Categories

(Core :: JavaScript Engine, defect)

x86
macOS
defect

Tracking

()

People

(Reporter: dhtmlkitchen, Unassigned)

Details

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(){
|   this.name = "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?

Dave
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
Assignee: general → nobody
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.