diff --git a/ets2panda/parser/ETSparser.cpp b/ets2panda/parser/ETSparser.cpp index eb1fabd6b92dc1057c1502344c0b782f65628657..affb924ae05d56068ddfd1fa84e85e26bb88c08f 100644 --- a/ets2panda/parser/ETSparser.cpp +++ b/ets2panda/parser/ETSparser.cpp @@ -2171,7 +2171,7 @@ ir::TSTypeParameter *ETSParser::ParseTypeParameter([[maybe_unused]] TypeAnnotati } } auto saveLoc = Lexer()->GetToken().Start(); - auto *paramIdent = ExpectIdentifier(false, false, *options); + auto *paramIdent = ExpectIdentifier(false, false, *options | TypeAnnotationParsingOptions::REPORT_ERROR); ir::TypeNode *constraint = nullptr; if (Lexer()->GetToken().Type() == lexer::TokenType::KEYW_EXTENDS) { diff --git a/ets2panda/test/ast/parser/ets/lambda_type_parameter_neg.ets b/ets2panda/test/ast/parser/ets/lambda_type_parameter_neg.ets new file mode 100644 index 0000000000000000000000000000000000000000..51573652ab5428c15d859d5d0c152bc09d82880d --- /dev/null +++ b/ets2panda/test/ast/parser/ets/lambda_type_parameter_neg.ets @@ -0,0 +1,21 @@ +/* + * 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. + */ + +let a = Int>(reader); + +/* @@? 16:14 Error SyntaxError: Identifier expected, got '('. */ +/* @@? 16:15 Error SyntaxError: Variable must be initialized or it's type must be declared. */ +/* @@? 16:15 Error SyntaxError: Unexpected token ')'. */ +/* @@? 16:17 Error SyntaxError: Unexpected token '=>'. */