grammars-v4
grammars-v4 copied to clipboard
[javascript] Field declaration should end with ';'
Code:
class Foo {
bar baz;
}
The code isn't correct according to documentation https://tc39.es/ecma262/multipage/ecmascript-language-functions-and-classes.html#prod-ClassElement and parsing should fail.
Yes, I just saw this last week while scraping the Spec. But, it turns out that Node, which is built on V8, accepts the field with or without the semi-colon. So, what is "JavaScript"? Is the ECMAScript Spec correct? How is javascript and ecmascript supposed to differ in this repo?
Good question. I've checked Firefox and it allows a field declaration without semicolon so the code below is OK
class Foo {
bar
baz
}
but
class Foo {
bar baz
}
is not OK and throws
Uncaught SyntaxError: unexpected token: identifier debugger eval code:2:8
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Missing_semicolon_before_statement