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
[JSC] Generator declaration should not be allowed in single statement context
https://bugs.webkit.org/show_bug.cgi?id=216720
Reviewed by Ross Kirsling.
JSTests:
* stress/generator-syntax.js:
(testSyntaxError.gen):
* test262/expectations.yaml:
Source/JavaScriptCore:
Generator declaration in single statement context (like the following code) should be syntax error.
We already made async function / async generator function syntax error. We should apply the same rule
to generator declaration too.
if (false)
function * gen() { }
* parser/Parser.cpp:
(JSC::Parser<LexerType>::parseSingleFunction):
(JSC::Parser<LexerType>::parseStatement):
(JSC::Parser<LexerType>::parseFunctionDeclarationStatement):
(JSC::Parser<LexerType>::parseFunctionDeclaration):
(JSC::Parser<LexerType>::parseExportDeclaration):
* parser/Parser.h:
Canonical link: https://commits.webkit.org/229530@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267306 268f45cc-cd09-0410-ab3c-d52691b4dbfc
semanticFailIfTrue(strictMode(), "Function declarations are only allowed inside blocks or switch statements in strict mode");
2029
2028
failIfFalse(parentAllowsFunctionDeclarationAsStatement, "Function declarations are only allowed inside block statements or at the top level of a program");
0 commit comments