From 1a8af90cce2a77f4500254583eb9fe2dc4ee097a Mon Sep 17 00:00:00 2001 From: daizihan Date: Sat, 19 Jul 2025 16:14:51 +0800 Subject: [PATCH] Cherry-pick !7233: Fix fuzz crash Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICPNLX?from=project-issue Signed-off-by: daizihan --- ets2panda/checker/ets/typeCheckingHelpers.cpp | 3 ++- ets2panda/test/runtime/ets/any_lambda.ets | 22 +++++++++++++++++++ .../test-lists/recheck/recheck-ignored.txt | 1 + 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 ets2panda/test/runtime/ets/any_lambda.ets diff --git a/ets2panda/checker/ets/typeCheckingHelpers.cpp b/ets2panda/checker/ets/typeCheckingHelpers.cpp index a2a5bb63d31..667c1f6fa4c 100644 --- a/ets2panda/checker/ets/typeCheckingHelpers.cpp +++ b/ets2panda/checker/ets/typeCheckingHelpers.cpp @@ -1463,7 +1463,8 @@ bool ETSChecker::CheckLambdaAssignable(ir::Expression *param, ir::ScriptFunction if (typeAnn == nullptr) { return false; } - if (typeAnn->IsETSTypeReference() && !typeAnn->AsETSTypeReference()->TsType()->IsETSArrayType()) { + if (typeAnn->IsETSTypeReference() && !typeAnn->AsETSTypeReference()->TsType()->IsETSArrayType() && + !typeAnn->AsETSTypeReference()->TsType()->IsETSAnyType()) { typeAnn = DerefETSTypeReference(typeAnn); } diff --git a/ets2panda/test/runtime/ets/any_lambda.ets b/ets2panda/test/runtime/ets/any_lambda.ets new file mode 100644 index 00000000000..0109a050332 --- /dev/null +++ b/ets2panda/test/runtime/ets/any_lambda.ets @@ -0,0 +1,22 @@ +/* + * 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 foo(a: Any) { +} + +function main() { + foo(() => {}); + arktest.assertTrue(true); +} diff --git a/ets2panda/test/test-lists/recheck/recheck-ignored.txt b/ets2panda/test/test-lists/recheck/recheck-ignored.txt index 7d0a9e40aba..15bc7d860cc 100644 --- a/ets2panda/test/test-lists/recheck/recheck-ignored.txt +++ b/ets2panda/test/test-lists/recheck/recheck-ignored.txt @@ -1480,5 +1480,6 @@ runtime/ets/objectLiteral.ets runtime/ets/objectLiteralInterfaceType.ets runtime/ets/objectLiteral_abstract_class_object.ets runtime/ets/rest_object_literal.ets +runtime/ets/any_lambda.ets ast/parser/ets/while_with_empty_body.ets ast/parser/ets/de_while_with_empty_body.ets -- Gitee