RESOLVED CONFIGURATION CHANGED 209675
[JSC] public-class-field should accept "get" / "set" fields
https://bugs.webkit.org/show_bug.cgi?id=209675
Summary [JSC] public-class-field should accept "get" / "set" fields
Yusuke Suzuki
Reported 2020-03-27 12:16:31 PDT
Example code. class A { static async get test() { } }
Attachments
Yusuke Suzuki
Comment 1 2020-03-27 12:17:41 PDT
Exception: SyntaxError: Unexpected identifier 'get'. Expected an opening '(' before a method's parameter list.
Caio Lima
Comment 2 2020-03-28 08:25:22 PDT
(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
Comment 3 2021-02-01 02:41:13 PST
It is fixed at some point.
Note You need to log in before you can comment on or make changes to this bug.