From febc7d3cd63eefe91c7aaa95e3a274a0b44e353e Mon Sep 17 00:00:00 2001 From: Veikka Tuominen Date: Tue, 31 May 2022 16:21:36 +0300 Subject: [PATCH] Sema: take `dbg_stmt` into account in `zirResolveInferredAlloc` --- src/Sema.zig | 2 +- test/behavior/basic.zig | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Sema.zig b/src/Sema.zig index 505810a158..ed8391a44d 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -2976,7 +2976,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com // Even though we reuse the constant instruction, we still remove it from the // block so that codegen does not see it. - block.instructions.shrinkRetainingCapacity(block.instructions.items.len - 3); + block.instructions.shrinkRetainingCapacity(search_index); sema.air_values.items[value_index] = try Value.Tag.decl_ref.create(sema.arena, new_decl_index); // if bitcast ty ref needs to be made const, make_ptr_const // ZIR handles it later, so we can just use the ty ref here. diff --git a/test/behavior/basic.zig b/test/behavior/basic.zig index e887a1d4b6..8bc1ad5cf2 100644 --- a/test/behavior/basic.zig +++ b/test/behavior/basic.zig @@ -977,3 +977,13 @@ test "weird array and tuple initializations" { .b = if (a) .{ .e = .a } else .{ .e = .b }, }; } + +test "array type comes from generic function" { + const S = struct { + fn A() type { + return struct { a: u8 = 0 }; + } + }; + const args = [_]S.A(){.{}}; + _ = args; +}