From 0ea65453652a9bdc832c9b8c08af345537d9f94b Mon Sep 17 00:00:00 2001 From: daizihan Date: Fri, 29 Aug 2025 15:55:28 +0800 Subject: [PATCH] Fix overload crash Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICVG9L?from=project-issue Signed-off-by: daizihan --- ets2panda/checker/ets/function.cpp | 1 + .../test/ast/compiler/ets/overload_crash.ets | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 ets2panda/test/ast/compiler/ets/overload_crash.ets diff --git a/ets2panda/checker/ets/function.cpp b/ets2panda/checker/ets/function.cpp index f42c123c76..ceed3c0dd3 100644 --- a/ets2panda/checker/ets/function.cpp +++ b/ets2panda/checker/ets/function.cpp @@ -727,6 +727,7 @@ bool ETSChecker::ValidateSignatureRestParams(Signature *substitutedSig, const Ar if (!invocationCtx.IsInvocable()) { if (restArgument->IsArrayExpression()) { ModifyPreferredType(restArgument->AsArrayExpression(), nullptr); + argument->SetTsType(nullptr); } return false; } diff --git a/ets2panda/test/ast/compiler/ets/overload_crash.ets b/ets2panda/test/ast/compiler/ets/overload_crash.ets new file mode 100644 index 0000000000..7350e84edd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/overload_crash.ets @@ -0,0 +1,26 @@ +/* + * 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 path(); +function path(obj: Object, ...keys: (string | number)[]); +function path(obj: Object, ...keys: (string | number)[]) { +} + +function f1(thing: string) { + path(thing, ...['a']); +} + +/* @@? 16:10 Error TypeError: Only abstract or native methods can't have body. */ +/* @@? 18:1 Error TypeError: Function path with this assembly signature already declared. */ -- Gitee