diff --git a/ets2panda/parser/ETSFormattedParser.cpp b/ets2panda/parser/ETSFormattedParser.cpp index cfda403d427a7b9c0ebc983d7b8f5b745204cfb3..b2e9c03b74f1cdbff1a8b041da8b21c5b42c7d9f 100644 --- a/ets2panda/parser/ETSFormattedParser.cpp +++ b/ets2panda/parser/ETSFormattedParser.cpp @@ -106,8 +106,8 @@ ir::TypeNode *ETSParser::ParseTypeFormatPlaceholder(std::optionalGetToken().Start()); - ES2PANDA_UNREACHABLE(); + LogUnexpectedToken(lexer::TokenType::PUNCTUATOR_FORMAT); + return AllocBrokenType(Lexer()->GetToken().Loc()); } nodeFormat = GetFormatPlaceholderType(); diff --git a/ets2panda/test/ast/parser/ets/invalid_punctuator_format.ets b/ets2panda/test/ast/parser/ets/invalid_punctuator_format.ets new file mode 100644 index 0000000000000000000000000000000000000000..2eba0019b69d4a8da790cfad2bc98cd8fa23d3cc --- /dev/null +++ b/ets2panda/test/ast/parser/ets/invalid_punctuator_format.ets @@ -0,0 +1,27 @@ +/* + * 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. + */ + +interface I { +J* @@? +} + +/* @@? 17:2 Error SyntaxError: Interface fields must have type annotation. */ +/* @@? 17:4 Error SyntaxError: Unexpected token '@@'. */ +/* @@? 17:4 Error SyntaxError: Unexpected token, expected ','. */ +/* @@? 17:4 Error SyntaxError: Unexpected token, expected 'private' or identifier. */ +/* @@? 17:6 Error SyntaxError: Identifier expected. */ +/* @@? 17:6 Error SyntaxError: Unexpected token, expected ','. */ +/* @@? 17:6 Error SyntaxError: Unexpected token, expected 'private' or identifier. */ +/* @@? 18:1 Error SyntaxError: Identifier expected. */