diff --git a/ets2panda/parser/ETSparser.cpp b/ets2panda/parser/ETSparser.cpp index 73ab94b616b1e7374ef3ad0cbca3debb0c08d65c..77c5b419318f92156129b141f0484b0a0268de77 100644 --- a/ets2panda/parser/ETSparser.cpp +++ b/ets2panda/parser/ETSparser.cpp @@ -2240,6 +2240,7 @@ bool ETSParser::ParseOverloadListElement(ArenaVector &overload while (Lexer()->TryEatTokenType(lexer::TokenType::PUNCTUATOR_PERIOD)) { if (Lexer()->GetToken().Type() != lexer::TokenType::LITERAL_IDENT) { LogExpectedToken(lexer::TokenType::LITERAL_IDENT); + return false; } auto *identNode = AllocNode(Lexer()->GetToken().Ident(), Allocator()); identNode->SetRange(Lexer()->GetToken().Loc()); diff --git a/ets2panda/test/ast/compiler/ets/first_match/invalid_declaration_5.ets b/ets2panda/test/ast/compiler/ets/first_match/invalid_declaration_5.ets new file mode 100644 index 0000000000000000000000000000000000000000..c7a80816f02fbb0dec419f0ca02691fb0e1239bb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/first_match/invalid_declaration_5.ets @@ -0,0 +1,23 @@ +/* + * 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. + */ + +overload foo{ foo.,T,} + +/* @@? 16:19 Error SyntaxError: Unexpected token, expected an identifier. */ +/* @@? 16:19 Error TypeError: overloaded name must refer to an accessible method. */ +/* @@? 16:20 Error SyntaxError: Unexpected token, expected ',' or '}'. */ +/* @@? 16:20 Error TypeError: Unresolved reference T */ +/* @@? 16:21 Error SyntaxError: Unexpected token ','. */ +/* @@? 16:22 Error SyntaxError: Unexpected token '}'. */