diff --git a/es2panda/parser/parserImpl.cpp b/es2panda/parser/parserImpl.cpp index 212fc8f3e337de54604804fabdb1ea34d2ac1bdf..4c44ee5f1e41ff53a13f63a25a90dd076249f04a 100644 --- a/es2panda/parser/parserImpl.cpp +++ b/es2panda/parser/parserImpl.cpp @@ -2650,9 +2650,7 @@ bool ParserImpl::IsMethodDefinitionsAreSame(const ir::MethodDefinition *property ir::Identifier *ParserImpl::SetIdentNodeInClassDefinition() { lexer::TokenType keywType = lexer_->GetToken().KeywordType(); - if (keywType >= lexer::TokenType::KEYW_STATIC) { - ThrowSyntaxError("Unexpected reserved word"); - } + CheckStrictReservedWord(); if (keywType == lexer::TokenType::KEYW_AWAIT && context_.IsModule()) { ThrowSyntaxError("Unexpected reserved word"); diff --git a/es2panda/test/parser/js/class-declaration-is-expected.txt b/es2panda/test/parser/js/class-declaration-is-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..f83f21df9659b91bd6d62e9d29563c21a74435fe --- /dev/null +++ b/es2panda/test/parser/js/class-declaration-is-expected.txt @@ -0,0 +1,139 @@ +{ + "type": "Program", + "statements": [ + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "is", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 9 + } + } + }, + "superClass": null, + "implements": [], + "constructor": { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "constructor", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": null, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 12 + } + } + }, + "body": [], + "indexSignatures": [], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 12 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 12 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 12 + } + } +} diff --git a/es2panda/test/parser/js/class-declaration-is.js b/es2panda/test/parser/js/class-declaration-is.js new file mode 100644 index 0000000000000000000000000000000000000000..2e8c0c369ba03373569e869ea1ac63f4e754eb45 --- /dev/null +++ b/es2panda/test/parser/js/class-declaration-is.js @@ -0,0 +1 @@ +class is {} \ No newline at end of file