diff --git a/src/Sema.zig b/src/Sema.zig index 022d522c35..465a3ceb1b 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -15966,8 +15966,8 @@ fn zirStructInit( const first_item = sema.code.extraData(Zir.Inst.StructInit.Item, extra.end).data; const first_field_type_data = zir_datas[first_item.field_type].pl_node; const first_field_type_extra = sema.code.extraData(Zir.Inst.FieldType, first_field_type_data.payload_index).data; - const unresolved_struct_type = try sema.resolveType(block, src, first_field_type_extra.container_type); - const resolved_ty = try sema.resolveTypeFields(block, src, unresolved_struct_type); + const resolved_ty = try sema.resolveType(block, src, first_field_type_extra.container_type); + try sema.resolveTypeLayout(block, src, resolved_ty); if (resolved_ty.zigTypeTag() == .Struct) { // This logic must be synchronized with that in `zirStructInitEmpty`. diff --git a/test/behavior.zig b/test/behavior.zig index 552e68f1f7..febd765d77 100644 --- a/test/behavior.zig +++ b/test/behavior.zig @@ -93,6 +93,7 @@ test { _ = @import("behavior/bugs/12794.zig"); _ = @import("behavior/bugs/12801-1.zig"); _ = @import("behavior/bugs/12801-2.zig"); + _ = @import("behavior/bugs/12911.zig"); _ = @import("behavior/bugs/12928.zig"); _ = @import("behavior/byteswap.zig"); _ = @import("behavior/byval_arg_var.zig"); diff --git a/test/behavior/bugs/12911.zig b/test/behavior/bugs/12911.zig new file mode 100644 index 0000000000..13e2dc19e4 --- /dev/null +++ b/test/behavior/bugs/12911.zig @@ -0,0 +1,11 @@ +const builtin = @import("builtin"); + +const Item = struct { field: u8 }; +const Thing = struct { + array: [1]Item, +}; +test { + if (builtin.zig_backend == .stage1) return error.SkipZigTest; + + _ = Thing{ .array = undefined }; +}