[webkit-changes] [WebKit/WebKit] 83c375: [JSC] Disallow yield/await expressions in class fi...
Dan Hecht
noreply at github.com
Tue Aug 27 14:54:03 PDT 2024
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 83c375677006369e1f00216b5640eaf3e6850d01
https://github.com/WebKit/WebKit/commit/83c375677006369e1f00216b5640eaf3e6850d01
Author: Dan Hecht <dan.hecht at apple.com>
Date: 2024-08-27 (Tue, 27 Aug 2024)
Changed paths:
A JSTests/stress/yield-await-class-field-initializer-expr.js
M Source/JavaScriptCore/parser/Parser.cpp
M Source/JavaScriptCore/parser/Parser.h
Log Message:
-----------
[JSC] Disallow yield/await expressions in class field initializers
https://bugs.webkit.org/show_bug.cgi?id=278589
rdar://132338331
Reviewed by Yusuke Suzuki.
The language spec doesn't explictly disallow yield and await expressions
in class field initializers, however it implicitly does given that
the expression is effectively evaluated as if it's inside a method.
Additionally, the consensus seems to be that these expressions
should not be allowed, see:
https://github.com/tc39/ecma262/issues/3333
The yield and await expressions are now handled differently, but
similar to how they are each handled in other contexts. This also
seems to be the least disruptive way to handle existing scripts,
as well as consistent with other engines:
yield: raise syntax error
await: parse as an identifier
However, if the field initializer expression is an async function
expression, then 'await' is allowed within that expression.
Also adding a new test that generates and verifies scripts containing
a class with a field initializer containing yield and await, where the
class is either not nested or nested inside generator or async functions
to verify the behavior of various combinations.
* JSTests/stress/yield-await-class-field-initializer-expr.js: Added.
(genTestCases):
(genTestScript.append):
(genTestScript):
(expected):
(testNegativeCases):
(testPositiveCases.assertEq):
(testPositiveCases.yieldFn0):
* Source/JavaScriptCore/parser/Parser.cpp:
(JSC::Parser<LexerType>::parseFunctionBody):
(JSC::Parser<LexerType>::parseClass):
(JSC::Parser<LexerType>::parseYieldExpression):
(JSC::Parser<LexerType>::parseAwaitExpression):
(JSC::Parser<LexerType>::parsePrimaryExpression):
(JSC::Parser<LexerType>::parseUnaryExpression):
* Source/JavaScriptCore/parser/Parser.h:
Canonical link: https://commits.webkit.org/282819@main
To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications
More information about the webkit-changes
mailing list