From 3a685ecb2400b397b1b091908536d55704792191 Mon Sep 17 00:00:00 2001 From: yanpeng51 Date: Fri, 27 Jun 2025 14:59:35 +0800 Subject: [PATCH] "Fixing Compilation Problems" Issue:https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICIA7X Signed-off-by: yanpeng51 --- ets2panda/checker/ets/helpers.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ets2panda/checker/ets/helpers.cpp b/ets2panda/checker/ets/helpers.cpp index 2886671c98..a24de4f2e3 100644 --- a/ets2panda/checker/ets/helpers.cpp +++ b/ets2panda/checker/ets/helpers.cpp @@ -694,6 +694,12 @@ bool ETSChecker::CheckInit(ir::Identifier *ident, ir::TypeNode *typeAnnotation, { if (typeAnnotation == nullptr) { if (init->IsArrayExpression()) { + auto arrayExpr = init->AsArrayExpression(); + if (arrayExpr->Elements().empty()) { + LogError(diagnostic::CANNOT_INFER_OBJ_LIT, {ident->Name()}, ident->Start()); + return false; + } + annotationType = CheckArrayElements(init->AsArrayExpression()); } else if (init->IsETSNewArrayInstanceExpression()) { annotationType = init->AsETSNewArrayInstanceExpression()->TypeReference()->GetType(this); -- Gitee