From df44a56d5cbf4a5b5f4b19d12a370ea3970f5c57 Mon Sep 17 00:00:00 2001 From: zhaoshuting Date: Thu, 31 Jul 2025 17:35:53 +0800 Subject: [PATCH] Fix the issue of es2panda abort in HasFuntion Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICQ5UD Signed-off-by: zhaoshuting --- .../lowering/ets/restArgsLowering.cpp | 3 ++- .../ast/compiler/ets/null_pointer_error1.ets | 26 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 ets2panda/test/ast/compiler/ets/null_pointer_error1.ets diff --git a/ets2panda/compiler/lowering/ets/restArgsLowering.cpp b/ets2panda/compiler/lowering/ets/restArgsLowering.cpp index f65624403fc..247092a886e 100644 --- a/ets2panda/compiler/lowering/ets/restArgsLowering.cpp +++ b/ets2panda/compiler/lowering/ets/restArgsLowering.cpp @@ -207,7 +207,8 @@ ir::CallExpression *RestArgsLowering::TransformCallExpressionWithRestArgs(ir::Ca public_lib::Context *context) { checker::Type *calleeType = callExpr->Callee()->TsType(); - if (calleeType == nullptr || calleeType->IsETSArrowType() || callExpr->Signature()->Function()->IsDynamic()) { + if (calleeType == nullptr || calleeType->IsETSArrowType() || + (callExpr->Signature() != nullptr && callExpr->Signature()->Function()->IsDynamic())) { return callExpr; } diff --git a/ets2panda/test/ast/compiler/ets/null_pointer_error1.ets b/ets2panda/test/ast/compiler/ets/null_pointer_error1.ets new file mode 100644 index 00000000000..1d92528ee16 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/null_pointer_error1.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. + */ + +const mustChecks: Array = new Array(); + +function mustCallArgSize() { + mustChecks.push(() => { + xf(){ + + } + }); +} + +/* @@? 20:9 Error TypeError: Variable 'xf' is accessed before it's initialization. */ -- Gitee