diff --git a/ets2panda/checker/ets/typeCheckingHelpers.cpp b/ets2panda/checker/ets/typeCheckingHelpers.cpp index bd526d218ded7c4dd18060506b552657d7582dc1..ae2b26c19f3375363dcd26f5fd0f9b62f1487acb 100644 --- a/ets2panda/checker/ets/typeCheckingHelpers.cpp +++ b/ets2panda/checker/ets/typeCheckingHelpers.cpp @@ -1435,7 +1435,7 @@ bool ETSChecker::CheckLambdaAssignable(ir::Expression *param, ir::ScriptFunction if (typeAnn == nullptr) { return false; } - if (typeAnn->IsETSTypeReference() && !typeAnn->AsETSTypeReference()->TsType()->IsETSArrayType()) { + if (typeAnn->IsETSTypeReference()) { typeAnn = util::Helpers::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 0000000000000000000000000000000000000000..0109a050332bb59c8fc9bdb54dcade7d4355e8ae --- /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 b1dc9d23c2b9fd90abf7a12f5e3c7f26783a8940..b933ebac4730bf089f4f7204c0a7173c701784b8 100644 --- a/ets2panda/test/test-lists/recheck/recheck-ignored.txt +++ b/ets2panda/test/test-lists/recheck/recheck-ignored.txt @@ -85,6 +85,7 @@ runtime/ets/lambda_with_receiver/lambda_with_receiver_trailing_in_class_method2. runtime/ets/lambda_with_receiver/lambda_with_receiver_trailing_in_function.ets runtime/ets/lambda_with_receiver/lambda_with_receiver_trailing_in_function_with_receiver.ets runtime/ets/lambda_with_receiver/lambda_with_receiver_trailing_name_duplicated.ets +runtime/ets/any_lambda.ets runtime/ets/generic_lambda_6.ets #Test that failed before CheckerPhase (on ConstantExpressionLowering) ast/parser/ets/InvalidLexer.ets diff --git a/ets2panda/util/helpers.cpp b/ets2panda/util/helpers.cpp index 37b43e97a80344974236972ce83daa8178b55935..86e899f655a40fc8a57be63704bc1dcc45ed3f34 100644 --- a/ets2panda/util/helpers.cpp +++ b/ets2panda/util/helpers.cpp @@ -819,10 +819,11 @@ ir::AstNode *Helpers::DerefETSTypeReference(ir::AstNode *node) ES2PANDA_ASSERT(node->IsETSTypeReference()); do { auto *name = node->AsETSTypeReference()->Part()->GetIdent(); - - ES2PANDA_ASSERT(name->IsIdentifier()); auto *var = name->AsIdentifier()->Variable(); - ES2PANDA_ASSERT(var != nullptr); + if (var == nullptr) { + // var == nullptr means it might be built-in type like Any type, which would cause unexpected crash below. + return node; + } auto *declNode = var->Declaration()->Node(); if (!declNode->IsTSTypeAliasDeclaration()) { return declNode;