Bug 209675
Summary: | [JSC] public-class-field should accept "get" / "set" fields | ||
---|---|---|---|
Product: | WebKit | Reporter: | Yusuke Suzuki <ysuzuki> |
Component: | JavaScriptCore | Assignee: | Yusuke Suzuki <ysuzuki> |
Status: | RESOLVED CONFIGURATION CHANGED | ||
Severity: | Normal | CC: | caitp, mark.lam, ross.kirsling, ticaiolima |
Priority: | P2 | ||
Version: | WebKit Nightly Build | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
See Also: | https://bugs.webkit.org/show_bug.cgi?id=209703 |
Yusuke Suzuki
Example code.
class A {
static
async
get
test() { }
}
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Yusuke Suzuki
Exception: SyntaxError: Unexpected identifier 'get'. Expected an opening '(' before a method's parameter list.
Caio Lima
(In reply to Yusuke Suzuki from comment #1)
> Exception: SyntaxError: Unexpected identifier 'get'. Expected an opening '('
> before a method's parameter list.
This is a tricky one, but I'm not sure if this is a legit bug. The message may sound confusing, but we could see this as the following program when we apply automatic semicolon insertion (ASI):
```
class A {
static
async;
get
test() { }
}
```
Since we don't support static class fields yet, the syntax error seems correct, given it is expected `function` or `PropertyName` after `async`(https://tc39.es/ecma262/#prod-AsyncFunctionDeclaration). A case that we could derivate from given example that parses correctly is:
```
class A {
async
get
test() { }
}
```
This should result in an object with field `async` and `get test`. We can define `get`
and `set` as field, but a `FieldDefinition` requires a semicolon (https://tc39.es/proposal-class-fields/#prod-ClassElement). Since `get` or `set` aren't restricted tokens, there is no ASI there and they are parsed as a setter/getter definition. I remember adding some tests for cases of `get`, `set`, `async` and `static` as field names, but I need to double check if it was here or in Test262. Anyway, increasing test coverage is almost never a bad idea.
Yusuke Suzuki
It is fixed at some point.