Open 12Me21 opened 1 year ago
This is true for all class fields where certain things follow it; that seems worth mentioning i guess.
I believe this can only happen with generator methods? oh- and methods/fields defined using ["name"] …
, I suppose?
But encountering a syntax error from a generator method in particular caught me off guard, since *
isn't on the list of "unsafe" characters (I assume this is because the only 'statement' which can begin with *
is a generator method inside a class block)
But encountering a syntax error from a generator method in particular caught me off guard, since
*
isn't on the list of "unsafe" characters
Inside class { ... }
, there are more hazards than “unsafe” characters. If you have a field named static
, get
or set
:
class foo {
static; // <-- non-guessable semicolon here
bar() { }
}
And yes, there should be a dedicated subsection inside “Interesting Cases of Automatic Semicolon Insertion” dedicated to class element lists.
Inside
class { ... }
, there are more hazards than “unsafe” characters. If you have a field namedstatic
,get
orset
:
Ah, gosh that's a terrifying edge case... (Though I'd probably quote the field name instead of using a semicolon, here)
Generator method definitions require a semicolon, when written immediately after a field definition. e.g:
Without that semicolon, this is a syntax error: the
*
is parsed as a multiplication operator, which causes the expression to continue across the linebreak (abc = 5 * func() {⚠️ ...
)I believe this should be mentioned in the "Interesting Cases of Automatic Semicolon Insertion" section?