closure-linter
closure-linter copied to clipboard
Bad missing semicolon error when (function() {})\n();
Sorry, but this is all about the edge cases:
$> cat breaking2.js
(function() {
console.log(1);
})
();
$> node breaking2.js
1
$> ./bin/fixjsstyle breaking2.js
Fixed 1 errors in breaking2.js
$> cat breaking2.js
(function() {
console.log(1);
});
();
$> node breaking2.js
breaking2.js:5
();
^
SyntaxError: Unexpected token )
at Module._compile (node.js:658:37)
at Module._loadScriptSync (node.js:669:10)
at Module.loadSync (node.js:538:12)
at Object.runMain (node.js:722:24)
at Array.0 (node.js:745:12)
at EventEmitter._tickCallback (node.js:55:22)
at node.js:757:9
Original issue reported on code.google.com by filip.noetzel on 24 Sep 2010 at 3:26
This is still in 2.2.6 :(
Original comment by filip.noetzel on 12 Nov 2010 at 8:26
Additional testcases (where semicolons are inserted with r7):
a = b + c
(d + e).print();
and
x()
();
.. the first one is actually taken from the ECMA-262 spec
http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf
§7.9.2 where it serves as an example where automatic semicolon insertion
should not happen.
Attached is a fix with these two testcases.
Original comment by filip.noetzel on 20 Feb 2011 at 8:22
Attachments: