From 74cd7258396fbd0e3ab2360baff1ebf4f568d9ad Mon Sep 17 00:00:00 2001 From: yp9522 Date: Mon, 14 Jul 2025 15:47:06 +0800 Subject: [PATCH] fix ValidateSignatureRequiredParams nullptr Issue:https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICM5F4 Signed-off-by: yp9522 --- ets2panda/checker/ets/function.cpp | 3 ++ .../ast/compiler/ets/builtin_thisArgs.ets | 37 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100755 ets2panda/test/ast/compiler/ets/builtin_thisArgs.ets diff --git a/ets2panda/checker/ets/function.cpp b/ets2panda/checker/ets/function.cpp index bf9e8520b4..ac40543021 100644 --- a/ets2panda/checker/ets/function.cpp +++ b/ets2panda/checker/ets/function.cpp @@ -413,6 +413,9 @@ bool ETSChecker::ValidateSignatureRequiredParams(Signature *substitutedSig, { auto commonArity = std::min(arguments.size(), substitutedSig->ArgCount()); if ((flags & TypeRelationFlag::NO_CHECK_TRAILING_LAMBDA) != 0) { + if (commonArity == 0) { + return true; + } commonArity = commonArity - 1; } for (size_t index = 0; index < commonArity; ++index) { diff --git a/ets2panda/test/ast/compiler/ets/builtin_thisArgs.ets b/ets2panda/test/ast/compiler/ets/builtin_thisArgs.ets new file mode 100755 index 0000000000..2d5aa7df6a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/builtin_thisArgs.ets @@ -0,0 +1,37 @@ +/* + * 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. + */ + +Class MyClass { + compare((value: number, index:number, arr: Array)) {} +} + +/* @@? 16:1 Error TypeError: Class name 'Class' used in the wrong context */ +/* @@? 16:7 Error SyntaxError: Unexpected token 'MyClass'. */ +/* @@? 16:7 Error TypeError: Unresolved reference MyClass */ +/* @@? 16:15 Error SyntaxError: Unexpected token '{'. */ +/* @@? 17:3 Error TypeError: Unresolved reference compare */ +/* @@? 17:17 Error SyntaxError: Unexpected token, expected ')'. */ +/* @@? 17:19 Error SyntaxError: Unexpected token, expected ',' or ')'. */ +/* @@? 17:19 Error SyntaxError: Unexpected token 'number'. */ +/* @@? 17:19 Error TypeError: Type name 'number' used in the wrong context */ +/* @@? 17:25 Error SyntaxError: Unexpected token ','. */ +/* @@? 17:27 Error SyntaxError: Unexpected token 'index'. */ +/* @@? 17:33 Error SyntaxError: Label must be followed by a loop statement. */ +/* @@? 17:33 Error TypeError: Type name 'number' used in the wrong context */ +/* @@? 17:39 Error SyntaxError: Unexpected token ','. */ +/* @@? 17:41 Error SyntaxError: Unexpected token 'arr'. */ +/* @@? 17:46 Error SyntaxError: Label must be followed by a loop statement. */ +/* @@? 17:46 Error TypeError: No matching call signature with trailing lambda */ +/* @@? 17:59 Error SyntaxError: Unexpected token, expected '('. */ \ No newline at end of file -- Gitee