⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 271432 in webkit


Ignore:
Timestamp:
Jan 12, 2021, 11:04:32 PM (6 years ago)
Author:
Ross Kirsling
Message:

[JSC] Class name 'await' is valid in sync context
https://bugs.webkit.org/show_bug.cgi?id=220575

Reviewed by Yusuke Suzuki.

JSTests:

  • test262/expectations.yaml:

Mark four test cases as passing.

Source/JavaScriptCore:

  • parser/Parser.cpp:

(JSC::Parser<LexerType>::parseClass):
Check for valid 'await'.

  • parser/Parser.h:

(JSC::Parser::isDisallowedIdentifierAwait):
Fix mistake -- we care if the containing function is async, we don't care about being *at* function scope.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r271423 r271432  
     12021-01-12  Ross Kirsling  <ross.kirsling@sony.com>
     2
     3        [JSC] Class name 'await' is valid in sync context
     4        https://bugs.webkit.org/show_bug.cgi?id=220575
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        * test262/expectations.yaml:
     9        Mark four test cases as passing.
     10
    1112021-01-12  Ross Kirsling  <ross.kirsling@sony.com>
    212
  • trunk/JSTests/test262/expectations.yaml

    r271423 r271432  
    14821482  default: "SyntaxError: Unexpected escaped characters in keyword token: 'aw\\u0061it'"
    14831483  strict mode: "SyntaxError: Unexpected escaped characters in keyword token: 'aw\\u0061it'"
    1484 test/language/expressions/class/class-name-ident-await.js:
    1485   default: "SyntaxError: Unexpected identifier 'await'. Expected opening '{' at the start of a class body."
    1486   strict mode: "SyntaxError: Unexpected identifier 'await'. Expected opening '{' at the start of a class body."
    14871484test/language/expressions/class/elements/arrow-body-direct-eval-err-contains-arguments.js:
    14881485  default: 'Test262Error: Expected a SyntaxError but got a ReferenceError'
     
    17371734  default: "SyntaxError: Unexpected escaped characters in keyword token: 'aw\\u0061it'"
    17381735  strict mode: "SyntaxError: Unexpected escaped characters in keyword token: 'aw\\u0061it'"
    1739 test/language/statements/class/class-name-ident-await.js:
    1740   default: "SyntaxError: Unexpected identifier 'await'"
    1741   strict mode: "SyntaxError: Unexpected identifier 'await'"
    17421736test/language/statements/class/elements/arrow-body-direct-eval-err-contains-arguments.js:
    17431737  default: 'Test262Error: Expected a SyntaxError but got a ReferenceError'
  • trunk/Source/JavaScriptCore/ChangeLog

    r271423 r271432  
     12021-01-12  Ross Kirsling  <ross.kirsling@sony.com>
     2
     3        [JSC] Class name 'await' is valid in sync context
     4        https://bugs.webkit.org/show_bug.cgi?id=220575
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        * parser/Parser.cpp:
     9        (JSC::Parser<LexerType>::parseClass):
     10        Check for valid 'await'.
     11
     12        * parser/Parser.h:
     13        (JSC::Parser::isDisallowedIdentifierAwait):
     14        Fix mistake -- we care if the containing function is async, we don't care about being *at* function scope.
     15
    1162021-01-12  Ross Kirsling  <ross.kirsling@sony.com>
    217
  • trunk/Source/JavaScriptCore/parser/Parser.cpp

    r271423 r271432  
    28612861    ASSERT_WITH_MESSAGE(requirements != FunctionNameRequirements::Unnamed, "Currently, there is no caller that uses FunctionNameRequirements::Unnamed for class syntax.");
    28622862    ASSERT_WITH_MESSAGE(!(requirements == FunctionNameRequirements::None && !info.className), "When specifying FunctionNameRequirements::None, we need to initialize info.className with the default value in the caller side.");
    2863     if (match(IDENT)) {
     2863    if (match(IDENT) || (match(AWAIT) && !isDisallowedIdentifierAwait(m_token))) {
    28642864        info.className = m_token.m_data.ident;
    28652865        next();
  • trunk/Source/JavaScriptCore/parser/Parser.h

    r270923 r271432  
    18431843    bool isDisallowedIdentifierAwait(const JSToken& token)
    18441844    {
    1845         return token.m_type == AWAIT && (!m_parserState.allowAwait || currentScope()->isAsyncFunctionBoundary() || m_scriptMode == JSParserScriptMode::Module);
     1845        return token.m_type == AWAIT && (!m_parserState.allowAwait || currentScope()->isAsyncFunction() || m_scriptMode == JSParserScriptMode::Module);
    18461846    }
    18471847
Note: See TracChangeset for help on using the changeset viewer.