diff --git a/ets2panda/checker/ets/function.cpp b/ets2panda/checker/ets/function.cpp index ea80a961c377bad8c0774150bebde324fc61cc1b..ee6117f0c70fa77b84ac8af55a2e859a719b4958 100644 --- a/ets2panda/checker/ets/function.cpp +++ b/ets2panda/checker/ets/function.cpp @@ -1595,6 +1595,10 @@ SignatureInfo *ETSChecker::ComposeSignatureInfo(ir::TSTypeParameterDeclaration * if (!params.empty()) { if (auto param = params.back()->AsETSParameterExpression(); param->IsRestParameter()) { if (param->TypeAnnotation() == nullptr) { // #23134 + if (param->RestParameter() != nullptr) { + LogError(diagnostic::REST_PARAM_MUST_HAVE_TYPE_ANNOTATION, {param->Name()}, param->Start()); + return nullptr; + } ES2PANDA_ASSERT(IsAnyError()); return nullptr; } diff --git a/ets2panda/test/ast/parser/ets/rest_param_lambda_type_interface.ets b/ets2panda/test/ast/parser/ets/rest_param_lambda_type_interface.ets new file mode 100644 index 0000000000000000000000000000000000000000..215caf9429f7dd0ead769afa5c9a4b20a08b12b2 --- /dev/null +++ b/ets2panda/test/ast/parser/ets/rest_param_lambda_type_interface.ets @@ -0,0 +1,18 @@ +/* +* 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 low 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. +*/ + +(...arg) => 102; + +/* @@? 16:2 Error TypeError: Rest parameter 'arg' must have an explicit type annotation. */ diff --git a/ets2panda/util/diagnostic/semantic.yaml b/ets2panda/util/diagnostic/semantic.yaml index 568a3b73128a4625368f0bb392f21c0762ebe352..cdcd1ab35c92a6ab3b98faecb093202285c813ad 100644 --- a/ets2panda/util/diagnostic/semantic.yaml +++ b/ets2panda/util/diagnostic/semantic.yaml @@ -1498,3 +1498,7 @@ semantic: - name: INTERFACE_EXTENDS_CLASS id: 373 message: "Interfaces cannot extend classes, only other interfaces." + +- name: REST_PARAM_MUST_HAVE_TYPE_ANNOTATION + id: 374 + message: "Rest parameter '{}' must have an explicit type annotation." \ No newline at end of file