From 4f21dc8a80d7b190d1812a668eaf570d377d95bf Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 21 Jun 2019 00:58:18 -0400 Subject: [PATCH] fix regression with zero sized array thanks mikdusan! --- src/ir.cpp | 3 +++ test/stage1/behavior/misc.zig | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/src/ir.cpp b/src/ir.cpp index 0645193454..828940a8ee 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -15200,6 +15200,9 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s return unwrapped_err_ptr; } } + } else if (is_slice(actual_elem_type) && value_type->id == ZigTypeIdArray) { + // need to allow EndExpr to do the implicit cast from array to slice + result_loc_pass1->written = false; } return result_loc; } diff --git a/test/stage1/behavior/misc.zig b/test/stage1/behavior/misc.zig index 28df26f9fa..d499df4cb7 100644 --- a/test/stage1/behavior/misc.zig +++ b/test/stage1/behavior/misc.zig @@ -698,3 +698,11 @@ test "unicode escape in character literal" { var a: u24 = '\U01f4a9'; expect(a == 128169); } + +test "result location zero sized array inside struct field implicit cast to slice" { + const E = struct { + entries: []u32, + }; + var foo = E{ .entries = [_]u32{} }; + expect(foo.entries.len == 0); +}