You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A class method named static is a SyntaxError, and get followed by a line break and a name without parameters is accepted #1729
Environment: XS 17.9.3, slot 32 bytes, ID 4 bytes (xst from Moddable SDK 9.5.0, the build the test262 CI installs; same commit as publicb6e06ba), Linux x86_64
Description
Two class element parsing problems, found with the new tests in tc39/test262#5142, which V8, SpiderMonkey, JavaScriptCore and GraalJS pass.
Steps to Reproduce
Run the snippets above with xst.
Expected behavior
static is a valid ClassElementName (ClassElementName : PropertyName, with static as an IdentifierName), so static() {} is a MethodDefinition named static. ( cannot start a ClassElementName, so it is not the static modifier, whether or not a line break comes first.
A SyntaxError. MethodDefinition : get ClassElementName ( ) { FunctionBody } has no [no LineTerminator here] after get, so a name on the next line is allowed and automatic semicolon insertion does not end the element after get. get a then needs a parameter list, and neither } nor a semicolon inserted before it completes the getter. V8, SpiderMonkey and JavaScriptCore throw a SyntaxError.
Actual behavior
SyntaxError: missing identifier.
The class parses with a single field a; the get is dropped. In test262 this shows as This statement should not be evaluated. for language/{statements,expressions}/class/elements/syntax/early-errors/grammar-get-followed-by-name-on-next-line-without-parameters-error.js; the other failing file is language/statements/class/elements/syntax/valid/grammar-method-named-static.js.
Other information
Getters and setters with a line break after get or set, and static followed by a line break and a method or field, already work in XS.
Activity