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
Commit 975467a
Browse filesBrowse the repository at this point in the historyBrowse files
async should be able to be used as an imported binding name
https://bugs.webkit.org/show_bug.cgi?id=176573
Reviewed by Darin Adler.
JSTests:
* modules/import-default-async.js: Added.
* modules/import-named-async-as.js: Added.
* modules/import-named-async.js: Added.
* modules/import-named-async/target.js: Added.
* modules/import-namespace-async.js: Added.
Source/JavaScriptCore:
Previously, we have ASYNC keyword in the parser. This is introduced only for performance,
and ECMA262 spec does not categorize "async" to keyword. This makes parser code complicated,
since ASYNC should be handled as IDENT. If we missed this ASYNC keyword, we cause a bug.
For example, import declaration failed to bind imported binding to the name "async" because
the parser considered ASYNC as keyword.
This patch removes ASYNC keyword from the parser. By carefully handling ASYNC, we can keep
the current performance without using this ASYNC keyword.
* parser/Keywords.table:
* parser/Parser.cpp:
(JSC::Parser<LexerType>::parseStatementListItem):
(JSC::Parser<LexerType>::parseStatement):
(JSC::Parser<LexerType>::maybeParseAsyncFunctionDeclarationStatement):
(JSC::Parser<LexerType>::parseClass):
(JSC::Parser<LexerType>::parseExportDeclaration):
(JSC::Parser<LexerType>::parseAssignmentExpression):
(JSC::Parser<LexerType>::parseProperty):
(JSC::Parser<LexerType>::parsePrimaryExpression):
(JSC::Parser<LexerType>::parseMemberExpression):
(JSC::Parser<LexerType>::printUnexpectedTokenText):
* parser/ParserTokens.h:
* runtime/CommonIdentifiers.h:
Canonical link: https://commits.webkit.org/194293@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223022 268f45cc-cd09-0410-ab3c-d52691b4dbfc
result = parseClassDeclaration(context, ExportType::Exported);
3515
3517
break;
3516
3518
3517
-
caseASYNC: {
3518
-
next();
3519
-
semanticFailIfFalse(match(FUNCTION) && !m_lexer->prevTerminator(), "Expected 'function' keyword following 'async' keyword with no preceding line terminator");
3520
-
DepthManager statementDepth(&m_statementDepth);
3521
-
m_statementDepth = 1;
3522
-
result = parseAsyncFunctionDeclaration(context, ExportType::Exported);
3523
-
break;
3524
-
}
3525
-
3519
+
caseIDENT:
3520
+
if (*m_token.m_data.ident == m_vm->propertyNames->async) {
3521
+
next();
3522
+
semanticFailIfFalse(match(FUNCTION) && !m_lexer->prevTerminator(), "Expected 'function' keyword following 'async' keyword with no preceding line terminator");
3523
+
DepthManager statementDepth(&m_statementDepth);
3524
+
m_statementDepth = 1;
3525
+
result = parseAsyncFunctionDeclaration(context, ExportType::Exported);
3526
+
break;
3527
+
}
3528
+
FALLTHROUGH;
3526
3529
default:
3527
3530
failWithMessage("Expected either a declaration or a variable statement");
0 commit comments