From 89a544c460f4606beca9dc7876fd4f8220794b8f Mon Sep 17 00:00:00 2001 From: yuanchaoxuan Date: Mon, 18 Aug 2025 09:37:03 +0800 Subject: [PATCH] Fix crash in objectLiteralLowering phase Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICSMYE Signed-off-by: yuanchaoxuan --- .../ets/interfaceObjectLiteralLowering.cpp | 3 +- .../ets/HandleInterfaceLowering_tuplerroe.ets | 32 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 ets2panda/test/runtime/ets/HandleInterfaceLowering_tuplerroe.ets diff --git a/ets2panda/compiler/lowering/ets/interfaceObjectLiteralLowering.cpp b/ets2panda/compiler/lowering/ets/interfaceObjectLiteralLowering.cpp index 1d889dee82..954ab38573 100644 --- a/ets2panda/compiler/lowering/ets/interfaceObjectLiteralLowering.cpp +++ b/ets2panda/compiler/lowering/ets/interfaceObjectLiteralLowering.cpp @@ -375,7 +375,8 @@ static void HandleInterfaceLowering(public_lib::Context *ctx, ir::ObjectExpressi resultType = instantiationCtx.Result(); } - if (const auto *const parent = objExpr->Parent(); parent->IsArrayExpression()) { + if (const auto *const parent = objExpr->Parent(); + parent->IsArrayExpression() && !parent->AsArrayExpression()->TsType()->IsETSTupleType()) { for (auto *elem : parent->AsArrayExpression()->Elements()) { if (elem->IsObjectExpression()) { elem->AsObjectExpression()->SetTsType(resultType); diff --git a/ets2panda/test/runtime/ets/HandleInterfaceLowering_tuplerroe.ets b/ets2panda/test/runtime/ets/HandleInterfaceLowering_tuplerroe.ets new file mode 100644 index 0000000000..aa7d2be563 --- /dev/null +++ b/ets2panda/test/runtime/ets/HandleInterfaceLowering_tuplerroe.ets @@ -0,0 +1,32 @@ +/* + * 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. + */ +interface ReadOnlyValue { + readonly value: number; +} +interface ReadOnlyName { + readonly name: string; +} + +type MappedTuple = [ReadOnlyValue, ReadOnlyName]; + +function main(): void { + let tuple: MappedTuple = [ + { value: 42 }, + { name: 'Alice' } + ]; + + arktest.assertEQ(tuple[0].value, 42); + arktest.assertEQ(tuple[1].name, 'Alice'); +} \ No newline at end of file -- Gitee