From 7e707f0dff2193acea050166ac8d6a1b721ef12f Mon Sep 17 00:00:00 2001 From: MuSilk Date: Fri, 29 Aug 2025 16:34:33 +0800 Subject: [PATCH] fix spreadlowering bug Issue: [Bug]: crash when spread expression argument is a lambda function and the function return a array with spread expression https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICVGWC Signed-off-by: MuSilk --- .../compiler/lowering/ets/spreadLowering.cpp | 2 +- .../runtime/ets/SpreadExpression_immcall.ets | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 ets2panda/test/runtime/ets/SpreadExpression_immcall.ets diff --git a/ets2panda/compiler/lowering/ets/spreadLowering.cpp b/ets2panda/compiler/lowering/ets/spreadLowering.cpp index fe71baaaf6..7bd6113966 100644 --- a/ets2panda/compiler/lowering/ets/spreadLowering.cpp +++ b/ets2panda/compiler/lowering/ets/spreadLowering.cpp @@ -386,10 +386,10 @@ bool SpreadConstructionPhase::PerformForModule(public_lib::Context *ctx, parser: // NOTE: this blockExpression is a kind of formatted-dummy code, which is invisible to users, // so, its source range should be same as the original code([element1, element2, ...spreadExpr]) blockExpression->SetRange(node->Range()); + Recheck(ctx->phaseManager, varbinder, checker, blockExpression); for (auto st : blockExpression->Statements()) { SetSourceRangesRecursively(st, node->Range()); } - Recheck(ctx->phaseManager, varbinder, checker, blockExpression); return blockExpression; } diff --git a/ets2panda/test/runtime/ets/SpreadExpression_immcall.ets b/ets2panda/test/runtime/ets/SpreadExpression_immcall.ets new file mode 100644 index 0000000000..469f896bd9 --- /dev/null +++ b/ets2panda/test/runtime/ets/SpreadExpression_immcall.ets @@ -0,0 +1,20 @@ +/* + * 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 main(){ + let a:string[] = ["1","2","3"] + let r = [...((p:string[]):string[] => [...p])(a),"4"] + arktest.assertTrue(String.join(r,"") == "1234") +} -- Gitee