From 32094db88e8e631da9d39a171d589196a4d0d4d1 Mon Sep 17 00:00:00 2001 From: chloe caruso Date: Sat, 27 Jul 2024 05:51:20 -0700 Subject: [PATCH] fix: crash when analyzing an empty array without a result type --- CHANGELOG.md | 1 + src/core/Transform.zig | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 66418ffbff568572d436dfeef86a4ef399602b3d..b00edae46ac5474bd10bce56c3d4e642612738ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ - fix: crash when printing unused struct declaration error - fix: provide array result type to sema +- fix: crash when analyzing an empty array without a result type ## 0.1.5 diff --git a/src/core/Transform.zig b/src/core/Transform.zig index 8a7580558dd07b0a3bd85ff8c32b0ae8f47ec644..b17994e6ef4b71c00ac73bfc6644ce7295553e2e 100644 --- a/src/core/Transform.zig +++ b/src/core/Transform.zig @@ -1391,6 +1391,10 @@ fn transformExpression( array_init.slice(&t.ast), ) orelse return null; + if (array_type == null and items.len == 0) { + return .empty_array; + } + return try t.addRef(.array_init, .{ .src_node = ctx.nodeOffset(node), .extra_index = try t.extra.append(t.gpa, Teg.ArrayInit, .{ -- 2.54.0