From 9a52abf3b47447b4ce976a99daca1c9c859c5aca Mon Sep 17 00:00:00 2001 From: Veikka Tuominen Date: Tue, 18 Oct 2022 19:11:54 +0300 Subject: [PATCH] Sema: add missing calls to `wip_captures.finalize` Closes #13171 --- src/Sema.zig | 2 ++ test/behavior.zig | 1 + test/behavior/bugs/13171.zig | 16 ++++++++++++++++ 3 files changed, 19 insertions(+) create mode 100644 test/behavior/bugs/13171.zig diff --git a/src/Sema.zig b/src/Sema.zig index 76e7e779e7..45dd182903 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -28775,6 +28775,7 @@ fn semaBackingIntType(mod: *Module, struct_obj: *Module.Struct) CompileError!voi try sema.checkBackingIntType(&block, backing_int_src, backing_int_ty, fields_bit_sum); struct_obj.backing_int_ty = try backing_int_ty.copy(decl_arena_allocator); + try wip_captures.finalize(); } else { var buf: Type.Payload.Bits = .{ .base = .{ .tag = .int_unsigned }, @@ -29386,6 +29387,7 @@ fn semaStructFields(mod: *Module, struct_obj: *Module.Struct) CompileError!void } } } + try wip_captures.finalize(); struct_obj.have_field_inits = true; } diff --git a/test/behavior.zig b/test/behavior.zig index b3c1654607..2f5d752087 100644 --- a/test/behavior.zig +++ b/test/behavior.zig @@ -108,6 +108,7 @@ test { _ = @import("behavior/bugs/13112.zig"); _ = @import("behavior/bugs/13128.zig"); _ = @import("behavior/bugs/13164.zig"); + _ = @import("behavior/bugs/13171.zig"); _ = @import("behavior/byteswap.zig"); _ = @import("behavior/byval_arg_var.zig"); _ = @import("behavior/call.zig"); diff --git a/test/behavior/bugs/13171.zig b/test/behavior/bugs/13171.zig new file mode 100644 index 0000000000..11579a7356 --- /dev/null +++ b/test/behavior/bugs/13171.zig @@ -0,0 +1,16 @@ +const std = @import("std"); +const expect = std.testing.expect; + +fn BuildType(comptime T: type) type { + return struct { + val: union { + b: T, + }, + }; +} + +test { + const TestStruct = BuildType(u32); + const c = TestStruct{ .val = .{ .b = 10 } }; + try expect(c.val.b == 10); +}