diff --git a/ets2panda/compiler/lowering/ets/spreadLowering.cpp b/ets2panda/compiler/lowering/ets/spreadLowering.cpp index fe71baaaf67590f856dc015f7b303a87fae37d15..7bd611396699f242067a26056e9546a655949d82 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 0000000000000000000000000000000000000000..469f896bd9dbe3e37945625c1ce0e1105c831fa9 --- /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") +}