diff --git a/ets2panda/checker/ets/function.cpp b/ets2panda/checker/ets/function.cpp index 40a06e17af9b5a2894557e434ade655b7d0a7743..3d4ca8c01870d01153442bafb01e1ed42f0d45cf 100644 --- a/ets2panda/checker/ets/function.cpp +++ b/ets2panda/checker/ets/function.cpp @@ -1584,9 +1584,11 @@ static bool AppendSignatureInfoParam(ETSChecker *checker, SignatureInfo *sigInfo return checker->GlobalTypeError(); }()); - if (variable == nullptr) { // #23134 + if (variable == nullptr || + (!checker->HasStatus(checker::CheckerStatus::IN_TYPE_INFER) && variable->TsType()->IsTypeError())) { // #23134 return false; } + if (param->IsRestParameter()) { return true; } diff --git a/ets2panda/test/ast/compiler/ets/invalid_option_param.ets b/ets2panda/test/ast/compiler/ets/invalid_option_param.ets new file mode 100644 index 0000000000000000000000000000000000000000..34c5ae324f666871a73692661724929dd3284c4c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/invalid_option_param.ets @@ -0,0 +1,25 @@ +/* + * 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. + */ + +function check(test? String): void { } + +/* @@? 16:10 Error TypeError: Only abstract or native methods can't have body. */ +/* @@? 16:16 Error TypeError: The type of parameter 'test' cannot be inferred */ +/* @@? 16:22 Error SyntaxError: Unexpected token, expected ',' or ')'. */ +/* @@? 16:22 Error SyntaxError: Class cannot be used as object. */ +/* @@? 16:28 Error SyntaxError: Unexpected token ')'. */ +/* @@? 16:29 Error SyntaxError: Unexpected token ':'. */ +/* @@? 16:31 Error SyntaxError: Unexpected token 'void'. */ +/* @@? 16:36 Error SyntaxError: Unexpected token '{'. */