Bug 209703 - [JSC] Public class field should accept "static" as field name
Summary: [JSC] Public class field should accept "static" as field name
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Caio Lima
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-03-28 09:28 PDT by Caio Lima
Modified: 2020-03-30 12:25 PDT (History)
11 users (show)

See Also:


Attachments
Patch (3.19 KB, patch)
2020-03-28 09:59 PDT, Caio Lima
no flags Details | Formatted Diff | Diff
Patch (3.37 KB, patch)
2020-03-30 07:36 PDT, Caio Lima
no flags Details | Formatted Diff | Diff
Patch (3.38 KB, patch)
2020-03-30 11:59 PDT, Caio Lima
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Caio Lima 2020-03-28 09:28:22 PDT
The following program should be valid, but throws a SyntaxError:

```
class A {
  super;
  static;
  set;
  get;
  test() { return "foo"; }
}
```
Comment 1 Caio Lima 2020-03-28 09:59:24 PDT
Created attachment 394826 [details]
Patch
Comment 2 Ross Kirsling 2020-03-28 12:56:39 PDT
Comment on attachment 394826 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=394826&action=review

> Source/JavaScriptCore/ChangeLog:8
> +        It allows class fields being created using "static" as identifier.

We should link to the spec here but unfortunately the PR is still unmerged.
(https://github.com/tc39/ecma262/pull/1668)

Since the idea is the same as other identifiers though, I suppose we could at least link to this:
https://tc39.es/ecma262/#prod-IdentifierName

> Source/JavaScriptCore/parser/Parser.cpp:2880
> +                // Reparse "static()" as a method named or "static" as a class field.

grammar nit: remove 'named'

> JSTests/stress/class-fields-harmony.js:909
> +{

I think Cait brought this file over from V8. Are we sure we want to make arbitrary edits here?
(https://github.com/v8/v8/blob/master/test/mjsunit/harmony/public-instance-class-fields.js)

Also, perhaps we should add this to test262? Because SM is currently failing too.
Comment 3 Caio Lima 2020-03-30 07:36:58 PDT
Created attachment 394916 [details]
Patch
Comment 4 Caio Lima 2020-03-30 07:37:31 PDT
Comment on attachment 394826 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=394826&action=review

Thank you very much for the review!

>> Source/JavaScriptCore/ChangeLog:8
>> +        It allows class fields being created using "static" as identifier.
> 
> We should link to the spec here but unfortunately the PR is still unmerged.
> (https://github.com/tc39/ecma262/pull/1668)
> 
> Since the idea is the same as other identifiers though, I suppose we could at least link to this:
> https://tc39.es/ecma262/#prod-IdentifierName

I agree. Added.

>> JSTests/stress/class-fields-harmony.js:909
>> +{
> 
> I think Cait brought this file over from V8. Are we sure we want to make arbitrary edits here?
> (https://github.com/v8/v8/blob/master/test/mjsunit/harmony/public-instance-class-fields.js)
> 
> Also, perhaps we should add this to test262? Because SM is currently failing too.

I'll place this in a separate file to avoid any issue. 

Test262 were added by https://github.com/tc39/test262/pull/2550
Comment 5 Ross Kirsling 2020-03-30 11:20:50 PDT
Comment on attachment 394916 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=394916&action=review

> JSTests/ChangeLog:8
> +        * stress/class-fields-harmony.js:

Oops, looks like the ChangeLog needs to be regenerated.
Comment 6 Caio Lima 2020-03-30 11:59:37 PDT
Created attachment 394944 [details]
Patch
Comment 7 Caio Lima 2020-03-30 12:00:43 PDT
Comment on attachment 394944 [details]
Patch

Thank you very much for the review!
Comment 8 EWS 2020-03-30 12:24:18 PDT
Committed r259216: <https://trac.webkit.org/changeset/259216>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 394944 [details].
Comment 9 Radar WebKit Bug Importer 2020-03-30 12:25:16 PDT
<rdar://problem/61067736>