diff --git a/ets2panda/parser/ETSparser.cpp b/ets2panda/parser/ETSparser.cpp index fff197fa753476379ecbecae8049ce8b4fe94b6d..bd175a4208b100e73397da520ffa2f880a710e84 100644 --- a/ets2panda/parser/ETSparser.cpp +++ b/ets2panda/parser/ETSparser.cpp @@ -610,6 +610,9 @@ ir::AstNode *ETSParser::ParseInnerTypeDeclaration(ir::ModifierFlags memberModifi Lexer()->GetToken().SetTokenType(Lexer()->GetToken().KeywordType()); ir::AstNode *typeDecl = ParseTypeDeclaration(true); + if (typeDecl == nullptr) { + return nullptr; + } memberModifiers &= (ir::ModifierFlags::PUBLIC | ir::ModifierFlags::PROTECTED | ir::ModifierFlags::PRIVATE | ir::ModifierFlags::INTERNAL); typeDecl->AddModifier(memberModifiers); diff --git a/ets2panda/test/ast/parser/ets/local-enum.ets b/ets2panda/test/ast/parser/ets/local-enum.ets new file mode 100644 index 0000000000000000000000000000000000000000..2e3a21b49c2cfbf661f330b8c092f0c1b7db522a --- /dev/null +++ b/ets2panda/test/ast/parser/ets/local-enum.ets @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +class A { + /* @@ label */enum E { + C + } +} + +/* @@@ label Error SyntaxError: Unexpected token. A constructor, method, accessor, or property was expected. */