diff options
author | Martok <martok@martoks-place.de> | 2022-06-17 21:12:01 +0200 |
---|---|---|
committer | Martok <martok@martoks-place.de> | 2022-06-17 21:12:01 +0200 |
commit | 324f6a0ea30ff1b8fc1ada50abc9e0bad986958b (patch) | |
tree | a5134fa04381736ed3af20106904adf09d89b05c /js | |
parent | a492c5bdb9802cf235ad69b879dd50aee6105c5f (diff) | |
download | uxp-324f6a0ea30ff1b8fc1ada50abc9e0bad986958b.tar.gz |
Issue #1918 - m-c 1353693: Correct parsing of async generator methods
Diffstat (limited to 'js')
-rw-r--r-- | js/src/frontend/Parser.cpp | 19 | ||||
-rw-r--r-- | js/src/frontend/Parser.h | 1 |
2 files changed, 15 insertions, 5 deletions
diff --git a/js/src/frontend/Parser.cpp b/js/src/frontend/Parser.cpp index f2d87f52be..cb84a939f6 100644 --- a/js/src/frontend/Parser.cpp +++ b/js/src/frontend/Parser.cpp @@ -7085,6 +7085,7 @@ JSOpFromPropertyType(PropertyType propType) case PropertyType::Method: case PropertyType::GeneratorMethod: case PropertyType::AsyncMethod: + case PropertyType::AsyncGeneratorMethod: case PropertyType::Constructor: case PropertyType::DerivedConstructor: return JSOP_INITPROP; @@ -7208,7 +7209,7 @@ Parser<ParseHandler>::classDefinition(YieldHandling yieldHandling, if (propType != PropertyType::Getter && propType != PropertyType::Setter && propType != PropertyType::Method && propType != PropertyType::GeneratorMethod && - propType != PropertyType::AsyncMethod && + propType != PropertyType::AsyncMethod && propType != PropertyType::AsyncGeneratorMethod && propType != PropertyType::Constructor && propType != PropertyType::DerivedConstructor) { errorAt(nameOffset, JSMSG_BAD_METHOD_DEF); @@ -9736,6 +9737,9 @@ Parser<ParseHandler>::propertyName(YieldHandling yieldHandling, // AsyncMethod[Yield, Await]: // async [no LineTerminator here] PropertyName[?Yield, ?Await] ... // + // AsyncGeneratorMethod[Yield, Await]: + // async [no LineTerminator here] * PropertyName[?Yield, ?Await] ... + // // PropertyName: // LiteralPropertyName // ComputedPropertyName[?Yield, ?Await] @@ -9751,7 +9755,7 @@ Parser<ParseHandler>::propertyName(YieldHandling yieldHandling, if (!tokenStream.peekTokenSameLine(&tt)) return null(); if (tt == TOK_STRING || tt == TOK_NUMBER || tt == TOK_LB || - TokenKindIsPossibleIdentifierName(tt)) + TokenKindIsPossibleIdentifierName(tt) || tt == TOK_MUL) { isAsync = true; tokenStream.consumeKnownToken(tt); @@ -9891,7 +9895,9 @@ Parser<ParseHandler>::propertyName(YieldHandling yieldHandling, if (tt == TOK_LP) { tokenStream.ungetToken(); - if (isGenerator) + if (isGenerator && isAsync) + *propType = PropertyType::AsyncGeneratorMethod; + else if (isGenerator) *propType = PropertyType::GeneratorMethod; else if (isAsync) *propType = PropertyType::AsyncMethod; @@ -10169,6 +10175,7 @@ Parser<ParseHandler>::methodDefinition(uint32_t toStringStart, PropertyType prop case PropertyType::Method: case PropertyType::GeneratorMethod: case PropertyType::AsyncMethod: + case PropertyType::AsyncGeneratorMethod: kind = Method; break; @@ -10184,11 +10191,13 @@ Parser<ParseHandler>::methodDefinition(uint32_t toStringStart, PropertyType prop MOZ_CRASH("Parser: methodDefinition: unexpected property type"); } - GeneratorKind generatorKind = propType == PropertyType::GeneratorMethod + GeneratorKind generatorKind = (propType == PropertyType::GeneratorMethod || + propType == PropertyType::AsyncGeneratorMethod) ? StarGenerator : NotGenerator; - FunctionAsyncKind asyncKind = (propType == PropertyType::AsyncMethod) + FunctionAsyncKind asyncKind = (propType == PropertyType::AsyncMethod || + propType == PropertyType::AsyncGeneratorMethod) ? AsyncFunction : SyncFunction; diff --git a/js/src/frontend/Parser.h b/js/src/frontend/Parser.h index 97f6917bd6..1e9028cbee 100644 --- a/js/src/frontend/Parser.h +++ b/js/src/frontend/Parser.h @@ -579,6 +579,7 @@ enum class PropertyType { Method, GeneratorMethod, AsyncMethod, + AsyncGeneratorMethod, Constructor, DerivedConstructor }; |