| ... | @@ -35277,7 +35277,7 @@ pub fn resolveStructAlignment( | ... | @@ -35277,7 +35277,7 @@ pub fn resolveStructAlignment( |
| 35277 | // might require explicit alignment. | 35277 | // might require explicit alignment. |
| 35278 | if (struct_type.assumePointerAlignedIfFieldTypesWip(ip, ptr_align)) return; | 35278 | if (struct_type.assumePointerAlignedIfFieldTypesWip(ip, ptr_align)) return; |
| 35279 | | 35279 | |
| 35280 | try sema.resolveTypeFieldsStruct(ty, struct_type); | 35280 | try sema.resolveStructFieldTypes(ty, struct_type); |
| 35281 | | 35281 | |
| 35282 | // We'll guess "pointer-aligned", if the struct has an | 35282 | // We'll guess "pointer-aligned", if the struct has an |
| 35283 | // underaligned pointer field then some allocations | 35283 | // underaligned pointer field then some allocations |
| ... | @@ -35316,7 +35316,7 @@ pub fn resolveStructLayout(sema: *Sema, ty: Type) SemaError!void { | ... | @@ -35316,7 +35316,7 @@ pub fn resolveStructLayout(sema: *Sema, ty: Type) SemaError!void { |
| 35316 | try sema.resolveTypeFieldsStruct(ty.toIntern(), struct_type); | 35316 | try sema.resolveTypeFieldsStruct(ty.toIntern(), struct_type); |
| 35317 | | 35317 | |
| 35318 | if (struct_type.layout == .@"packed") { | 35318 | if (struct_type.layout == .@"packed") { |
| 35319 | semaBackingIntType(pt, struct_type) catch |err| switch (err) { | 35319 | sema.backingIntType(struct_type) catch |err| switch (err) { |
| 35320 | error.OutOfMemory, error.AnalysisFail => |e| return e, | 35320 | error.OutOfMemory, error.AnalysisFail => |e| return e, |
| 35321 | error.ComptimeBreak, error.ComptimeReturn, error.GenericPoison => unreachable, | 35321 | error.ComptimeBreak, error.ComptimeReturn, error.GenericPoison => unreachable, |
| 35322 | }; | 35322 | }; |
| ... | @@ -35444,38 +35444,26 @@ pub fn resolveStructLayout(sema: *Sema, ty: Type) SemaError!void { | ... | @@ -35444,38 +35444,26 @@ pub fn resolveStructLayout(sema: *Sema, ty: Type) SemaError!void { |
| 35444 | _ = try ty.comptimeOnlySema(pt); | 35444 | _ = try ty.comptimeOnlySema(pt); |
| 35445 | } | 35445 | } |
| 35446 | | 35446 | |
| 35447 | fn semaBackingIntType(pt: Zcu.PerThread, struct_type: InternPool.LoadedStructType) CompileError!void { | 35447 | fn backingIntType( |
| | 35448 | sema: *Sema, |
| | 35449 | struct_type: InternPool.LoadedStructType, |
| | 35450 | ) CompileError!void { |
| | 35451 | const pt = sema.pt; |
| 35448 | const zcu = pt.zcu; | 35452 | const zcu = pt.zcu; |
| 35449 | const gpa = zcu.gpa; | 35453 | const gpa = zcu.gpa; |
| 35450 | const ip = &zcu.intern_pool; | 35454 | const ip = &zcu.intern_pool; |
| 35451 | | 35455 | |
| 35452 | const cau_index = struct_type.cau.unwrap().?; | 35456 | const cau_index = struct_type.cau.unwrap().?; |
| 35453 | | 35457 | |
| 35454 | const zir = zcu.namespacePtr(struct_type.namespace.unwrap().?).fileScope(zcu).zir; | | |
| 35455 | | | |
| 35456 | var analysis_arena = std.heap.ArenaAllocator.init(gpa); | 35458 | var analysis_arena = std.heap.ArenaAllocator.init(gpa); |
| 35457 | defer analysis_arena.deinit(); | 35459 | defer analysis_arena.deinit(); |
| 35458 | | 35460 | |
| 35459 | var comptime_err_ret_trace = std.ArrayList(LazySrcLoc).init(gpa); | 35461 | var comptime_err_ret_trace = std.ArrayList(LazySrcLoc).init(gpa); |
| 35460 | defer comptime_err_ret_trace.deinit(); | 35462 | defer comptime_err_ret_trace.deinit(); |
| 35461 | | 35463 | |
| 35462 | var sema: Sema = .{ | | |
| 35463 | .pt = pt, | | |
| 35464 | .gpa = gpa, | | |
| 35465 | .arena = analysis_arena.allocator(), | | |
| 35466 | .code = zir, | | |
| 35467 | .owner = AnalUnit.wrap(.{ .cau = cau_index }), | | |
| 35468 | .func_index = .none, | | |
| 35469 | .func_is_naked = false, | | |
| 35470 | .fn_ret_ty = Type.void, | | |
| 35471 | .fn_ret_ty_ies = null, | | |
| 35472 | .comptime_err_ret_trace = &comptime_err_ret_trace, | | |
| 35473 | }; | | |
| 35474 | defer sema.deinit(); | | |
| 35475 | | | |
| 35476 | var block: Block = .{ | 35464 | var block: Block = .{ |
| 35477 | .parent = null, | 35465 | .parent = null, |
| 35478 | .sema = &sema, | 35466 | .sema = sema, |
| 35479 | .namespace = ip.getCau(cau_index).namespace, | 35467 | .namespace = ip.getCau(cau_index).namespace, |
| 35480 | .instructions = .{}, | 35468 | .instructions = .{}, |
| 35481 | .inlining = null, | 35469 | .inlining = null, |
| ... | @@ -35494,6 +35482,7 @@ fn semaBackingIntType(pt: Zcu.PerThread, struct_type: InternPool.LoadedStructTyp | ... | @@ -35494,6 +35482,7 @@ fn semaBackingIntType(pt: Zcu.PerThread, struct_type: InternPool.LoadedStructTyp |
| 35494 | break :blk accumulator; | 35482 | break :blk accumulator; |
| 35495 | }; | 35483 | }; |
| 35496 | | 35484 | |
| | 35485 | const zir = zcu.namespacePtr(struct_type.namespace.unwrap().?).fileScope(zcu).zir; |
| 35497 | const zir_index = struct_type.zir_index.unwrap().?.resolve(ip) orelse return error.AnalysisFail; | 35486 | const zir_index = struct_type.zir_index.unwrap().?.resolve(ip) orelse return error.AnalysisFail; |
| 35498 | const extended = zir.instructions.items(.data)[@intFromEnum(zir_index)].extended; | 35487 | const extended = zir.instructions.items(.data)[@intFromEnum(zir_index)].extended; |
| 35499 | assert(extended.opcode == .struct_decl); | 35488 | assert(extended.opcode == .struct_decl); |
| ... | @@ -35618,7 +35607,7 @@ pub fn resolveUnionAlignment( | ... | @@ -35618,7 +35607,7 @@ pub fn resolveUnionAlignment( |
| 35618 | // might require explicit alignment. | 35607 | // might require explicit alignment. |
| 35619 | if (union_type.assumePointerAlignedIfFieldTypesWip(ip, ptr_align)) return; | 35608 | if (union_type.assumePointerAlignedIfFieldTypesWip(ip, ptr_align)) return; |
| 35620 | | 35609 | |
| 35621 | try sema.resolveTypeFieldsUnion(ty, union_type); | 35610 | try sema.resolveUnionFieldTypes(ty, union_type); |
| 35622 | | 35611 | |
| 35623 | var max_align: Alignment = .@"1"; | 35612 | var max_align: Alignment = .@"1"; |
| 35624 | for (0..union_type.field_types.len) |field_index| { | 35613 | for (0..union_type.field_types.len) |field_index| { |
| ... | @@ -35642,7 +35631,7 @@ pub fn resolveUnionLayout(sema: *Sema, ty: Type) SemaError!void { | ... | @@ -35642,7 +35631,7 @@ pub fn resolveUnionLayout(sema: *Sema, ty: Type) SemaError!void { |
| 35642 | const pt = sema.pt; | 35631 | const pt = sema.pt; |
| 35643 | const ip = &pt.zcu.intern_pool; | 35632 | const ip = &pt.zcu.intern_pool; |
| 35644 | | 35633 | |
| 35645 | try sema.resolveTypeFieldsUnion(ty, ip.loadUnionType(ty.ip_index)); | 35634 | try sema.resolveUnionFieldTypes(ty, ip.loadUnionType(ty.ip_index)); |
| 35646 | | 35635 | |
| 35647 | // Load again, since the tag type might have changed due to resolution. | 35636 | // Load again, since the tag type might have changed due to resolution. |
| 35648 | const union_type = ip.loadUnionType(ty.ip_index); | 35637 | const union_type = ip.loadUnionType(ty.ip_index); |
| ... | @@ -35810,7 +35799,7 @@ pub fn resolveUnionFully(sema: *Sema, ty: Type) SemaError!void { | ... | @@ -35810,7 +35799,7 @@ pub fn resolveUnionFully(sema: *Sema, ty: Type) SemaError!void { |
| 35810 | _ = try ty.comptimeOnlySema(pt); | 35799 | _ = try ty.comptimeOnlySema(pt); |
| 35811 | } | 35800 | } |
| 35812 | | 35801 | |
| 35813 | pub fn resolveTypeFieldsStruct( | 35802 | pub fn resolveStructFieldTypes( |
| 35814 | sema: *Sema, | 35803 | sema: *Sema, |
| 35815 | ty: InternPool.Index, | 35804 | ty: InternPool.Index, |
| 35816 | struct_type: InternPool.LoadedStructType, | 35805 | struct_type: InternPool.LoadedStructType, |
| ... | @@ -35833,7 +35822,7 @@ pub fn resolveTypeFieldsStruct( | ... | @@ -35833,7 +35822,7 @@ pub fn resolveTypeFieldsStruct( |
| 35833 | } | 35822 | } |
| 35834 | defer struct_type.clearFieldTypesWip(ip); | 35823 | defer struct_type.clearFieldTypesWip(ip); |
| 35835 | | 35824 | |
| 35836 | semaStructFields(pt, sema.arena, struct_type) catch |err| switch (err) { | 35825 | sema.structFields(struct_type) catch |err| switch (err) { |
| 35837 | error.AnalysisFail, error.OutOfMemory => |e| return e, | 35826 | error.AnalysisFail, error.OutOfMemory => |e| return e, |
| 35838 | error.ComptimeBreak, error.ComptimeReturn, error.GenericPoison => unreachable, | 35827 | error.ComptimeBreak, error.ComptimeReturn, error.GenericPoison => unreachable, |
| 35839 | }; | 35828 | }; |
| ... | @@ -35862,14 +35851,14 @@ pub fn resolveStructFieldInits(sema: *Sema, ty: Type) SemaError!void { | ... | @@ -35862,14 +35851,14 @@ pub fn resolveStructFieldInits(sema: *Sema, ty: Type) SemaError!void { |
| 35862 | } | 35851 | } |
| 35863 | defer struct_type.clearInitsWip(ip); | 35852 | defer struct_type.clearInitsWip(ip); |
| 35864 | | 35853 | |
| 35865 | semaStructFieldInits(pt, sema.arena, struct_type) catch |err| switch (err) { | 35854 | sema.structFieldInits(struct_type) catch |err| switch (err) { |
| 35866 | error.AnalysisFail, error.OutOfMemory => |e| return e, | 35855 | error.AnalysisFail, error.OutOfMemory => |e| return e, |
| 35867 | error.ComptimeBreak, error.ComptimeReturn, error.GenericPoison => unreachable, | 35856 | error.ComptimeBreak, error.ComptimeReturn, error.GenericPoison => unreachable, |
| 35868 | }; | 35857 | }; |
| 35869 | struct_type.setHaveFieldInits(ip); | 35858 | struct_type.setHaveFieldInits(ip); |
| 35870 | } | 35859 | } |
| 35871 | | 35860 | |
| 35872 | pub fn resolveTypeFieldsUnion(sema: *Sema, ty: Type, union_type: InternPool.LoadedUnionType) SemaError!void { | 35861 | pub fn resolveUnionFieldTypes(sema: *Sema, ty: Type, union_type: InternPool.LoadedUnionType) SemaError!void { |
| 35873 | const pt = sema.pt; | 35862 | const pt = sema.pt; |
| 35874 | const zcu = pt.zcu; | 35863 | const zcu = pt.zcu; |
| 35875 | const ip = &zcu.intern_pool; | 35864 | const ip = &zcu.intern_pool; |
| ... | @@ -35896,7 +35885,7 @@ pub fn resolveTypeFieldsUnion(sema: *Sema, ty: Type, union_type: InternPool.Load | ... | @@ -35896,7 +35885,7 @@ pub fn resolveTypeFieldsUnion(sema: *Sema, ty: Type, union_type: InternPool.Load |
| 35896 | | 35885 | |
| 35897 | union_type.setStatus(ip, .field_types_wip); | 35886 | union_type.setStatus(ip, .field_types_wip); |
| 35898 | errdefer union_type.setStatus(ip, .none); | 35887 | errdefer union_type.setStatus(ip, .none); |
| 35899 | semaUnionFields(pt, sema.arena, ty.toIntern(), union_type) catch |err| switch (err) { | 35888 | sema.unionFields(ty.toIntern(), union_type) catch |err| switch (err) { |
| 35900 | error.AnalysisFail, error.OutOfMemory => |e| return e, | 35889 | error.AnalysisFail, error.OutOfMemory => |e| return e, |
| 35901 | error.ComptimeBreak, error.ComptimeReturn, error.GenericPoison => unreachable, | 35890 | error.ComptimeBreak, error.ComptimeReturn, error.GenericPoison => unreachable, |
| 35902 | }; | 35891 | }; |
| ... | @@ -36099,11 +36088,11 @@ fn structZirInfo(zir: Zir, zir_index: Zir.Inst.Index) struct { | ... | @@ -36099,11 +36088,11 @@ fn structZirInfo(zir: Zir, zir_index: Zir.Inst.Index) struct { |
| 36099 | return .{ fields_len, small, extra_index }; | 36088 | return .{ fields_len, small, extra_index }; |
| 36100 | } | 36089 | } |
| 36101 | | 36090 | |
| 36102 | fn semaStructFields( | 36091 | fn structFields( |
| 36103 | pt: Zcu.PerThread, | 36092 | sema: *Sema, |
| 36104 | arena: Allocator, | | |
| 36105 | struct_type: InternPool.LoadedStructType, | 36093 | struct_type: InternPool.LoadedStructType, |
| 36106 | ) CompileError!void { | 36094 | ) CompileError!void { |
| | 36095 | const pt = sema.pt; |
| 36107 | const zcu = pt.zcu; | 36096 | const zcu = pt.zcu; |
| 36108 | const gpa = zcu.gpa; | 36097 | const gpa = zcu.gpa; |
| 36109 | const ip = &zcu.intern_pool; | 36098 | const ip = &zcu.intern_pool; |
| ... | @@ -36116,7 +36105,7 @@ fn semaStructFields( | ... | @@ -36116,7 +36105,7 @@ fn semaStructFields( |
| 36116 | | 36105 | |
| 36117 | if (fields_len == 0) switch (struct_type.layout) { | 36106 | if (fields_len == 0) switch (struct_type.layout) { |
| 36118 | .@"packed" => { | 36107 | .@"packed" => { |
| 36119 | try semaBackingIntType(pt, struct_type); | 36108 | try sema.backingIntType(struct_type); |
| 36120 | return; | 36109 | return; |
| 36121 | }, | 36110 | }, |
| 36122 | .auto, .@"extern" => { | 36111 | .auto, .@"extern" => { |
| ... | @@ -36128,23 +36117,9 @@ fn semaStructFields( | ... | @@ -36128,23 +36117,9 @@ fn semaStructFields( |
| 36128 | var comptime_err_ret_trace = std.ArrayList(LazySrcLoc).init(gpa); | 36117 | var comptime_err_ret_trace = std.ArrayList(LazySrcLoc).init(gpa); |
| 36129 | defer comptime_err_ret_trace.deinit(); | 36118 | defer comptime_err_ret_trace.deinit(); |
| 36130 | | 36119 | |
| 36131 | var sema: Sema = .{ | | |
| 36132 | .pt = pt, | | |
| 36133 | .gpa = gpa, | | |
| 36134 | .arena = arena, | | |
| 36135 | .code = zir, | | |
| 36136 | .owner = AnalUnit.wrap(.{ .cau = cau_index }), | | |
| 36137 | .func_index = .none, | | |
| 36138 | .func_is_naked = false, | | |
| 36139 | .fn_ret_ty = Type.void, | | |
| 36140 | .fn_ret_ty_ies = null, | | |
| 36141 | .comptime_err_ret_trace = &comptime_err_ret_trace, | | |
| 36142 | }; | | |
| 36143 | defer sema.deinit(); | | |
| 36144 | | | |
| 36145 | var block_scope: Block = .{ | 36120 | var block_scope: Block = .{ |
| 36146 | .parent = null, | 36121 | .parent = null, |
| 36147 | .sema = &sema, | 36122 | .sema = sema, |
| 36148 | .namespace = namespace_index, | 36123 | .namespace = namespace_index, |
| 36149 | .instructions = .{}, | 36124 | .instructions = .{}, |
| 36150 | .inlining = null, | 36125 | .inlining = null, |
| ... | @@ -36318,12 +36293,12 @@ fn semaStructFields( | ... | @@ -36318,12 +36293,12 @@ fn semaStructFields( |
| 36318 | try sema.flushExports(); | 36293 | try sema.flushExports(); |
| 36319 | } | 36294 | } |
| 36320 | | 36295 | |
| 36321 | // This logic must be kept in sync with `semaStructFields` | 36296 | // This logic must be kept in sync with `structFields` |
| 36322 | fn semaStructFieldInits( | 36297 | fn structFieldInits( |
| 36323 | pt: Zcu.PerThread, | 36298 | sema: *Sema, |
| 36324 | arena: Allocator, | | |
| 36325 | struct_type: InternPool.LoadedStructType, | 36299 | struct_type: InternPool.LoadedStructType, |
| 36326 | ) CompileError!void { | 36300 | ) CompileError!void { |
| | 36301 | const pt = sema.pt; |
| 36327 | const zcu = pt.zcu; | 36302 | const zcu = pt.zcu; |
| 36328 | const gpa = zcu.gpa; | 36303 | const gpa = zcu.gpa; |
| 36329 | const ip = &zcu.intern_pool; | 36304 | const ip = &zcu.intern_pool; |
| ... | @@ -36339,23 +36314,9 @@ fn semaStructFieldInits( | ... | @@ -36339,23 +36314,9 @@ fn semaStructFieldInits( |
| 36339 | var comptime_err_ret_trace = std.ArrayList(LazySrcLoc).init(gpa); | 36314 | var comptime_err_ret_trace = std.ArrayList(LazySrcLoc).init(gpa); |
| 36340 | defer comptime_err_ret_trace.deinit(); | 36315 | defer comptime_err_ret_trace.deinit(); |
| 36341 | | 36316 | |
| 36342 | var sema: Sema = .{ | | |
| 36343 | .pt = pt, | | |
| 36344 | .gpa = gpa, | | |
| 36345 | .arena = arena, | | |
| 36346 | .code = zir, | | |
| 36347 | .owner = AnalUnit.wrap(.{ .cau = cau_index }), | | |
| 36348 | .func_index = .none, | | |
| 36349 | .func_is_naked = false, | | |
| 36350 | .fn_ret_ty = Type.void, | | |
| 36351 | .fn_ret_ty_ies = null, | | |
| 36352 | .comptime_err_ret_trace = &comptime_err_ret_trace, | | |
| 36353 | }; | | |
| 36354 | defer sema.deinit(); | | |
| 36355 | | | |
| 36356 | var block_scope: Block = .{ | 36317 | var block_scope: Block = .{ |
| 36357 | .parent = null, | 36318 | .parent = null, |
| 36358 | .sema = &sema, | 36319 | .sema = sema, |
| 36359 | .namespace = namespace_index, | 36320 | .namespace = namespace_index, |
| 36360 | .instructions = .{}, | 36321 | .instructions = .{}, |
| 36361 | .inlining = null, | 36322 | .inlining = null, |
| ... | @@ -36458,14 +36419,18 @@ fn semaStructFieldInits( | ... | @@ -36458,14 +36419,18 @@ fn semaStructFieldInits( |
| 36458 | try sema.flushExports(); | 36419 | try sema.flushExports(); |
| 36459 | } | 36420 | } |
| 36460 | | 36421 | |
| 36461 | fn semaUnionFields(pt: Zcu.PerThread, arena: Allocator, union_ty: InternPool.Index, union_type: InternPool.LoadedUnionType) CompileError!void { | 36422 | fn unionFields( |
| | 36423 | sema: *Sema, |
| | 36424 | union_ty: InternPool.Index, |
| | 36425 | union_type: InternPool.LoadedUnionType, |
| | 36426 | ) CompileError!void { |
| 36462 | const tracy = trace(@src()); | 36427 | const tracy = trace(@src()); |
| 36463 | defer tracy.end(); | 36428 | defer tracy.end(); |
| 36464 | | 36429 | |
| | 36430 | const pt = sema.pt; |
| 36465 | const zcu = pt.zcu; | 36431 | const zcu = pt.zcu; |
| 36466 | const gpa = zcu.gpa; | 36432 | const gpa = zcu.gpa; |
| 36467 | const ip = &zcu.intern_pool; | 36433 | const ip = &zcu.intern_pool; |
| 36468 | const cau_index = union_type.cau; | | |
| 36469 | const zir = zcu.namespacePtr(union_type.namespace).fileScope(zcu).zir; | 36434 | const zir = zcu.namespacePtr(union_type.namespace).fileScope(zcu).zir; |
| 36470 | const zir_index = union_type.zir_index.resolve(ip) orelse return error.AnalysisFail; | 36435 | const zir_index = union_type.zir_index.resolve(ip) orelse return error.AnalysisFail; |
| 36471 | const extended = zir.instructions.items(.data)[@intFromEnum(zir_index)].extended; | 36436 | const extended = zir.instructions.items(.data)[@intFromEnum(zir_index)].extended; |
| ... | @@ -36513,10 +36478,12 @@ fn semaUnionFields(pt: Zcu.PerThread, arena: Allocator, union_ty: InternPool.Ind | ... | @@ -36513,10 +36478,12 @@ fn semaUnionFields(pt: Zcu.PerThread, arena: Allocator, union_ty: InternPool.Ind |
| 36513 | var comptime_err_ret_trace = std.ArrayList(LazySrcLoc).init(gpa); | 36478 | var comptime_err_ret_trace = std.ArrayList(LazySrcLoc).init(gpa); |
| 36514 | defer comptime_err_ret_trace.deinit(); | 36479 | defer comptime_err_ret_trace.deinit(); |
| 36515 | | 36480 | |
| 36516 | var sema: Sema = .{ | 36481 | const cau_index = union_type.cau; |
| | 36482 | |
| | 36483 | var inner_sema: Sema = .{ |
| 36517 | .pt = pt, | 36484 | .pt = pt, |
| 36518 | .gpa = gpa, | 36485 | .gpa = gpa, |
| 36519 | .arena = arena, | 36486 | .arena = sema.arena, |
| 36520 | .code = zir, | 36487 | .code = zir, |
| 36521 | .owner = AnalUnit.wrap(.{ .cau = cau_index }), | 36488 | .owner = AnalUnit.wrap(.{ .cau = cau_index }), |
| 36522 | .func_index = .none, | 36489 | .func_index = .none, |
| ... | @@ -36525,11 +36492,11 @@ fn semaUnionFields(pt: Zcu.PerThread, arena: Allocator, union_ty: InternPool.Ind | ... | @@ -36525,11 +36492,11 @@ fn semaUnionFields(pt: Zcu.PerThread, arena: Allocator, union_ty: InternPool.Ind |
| 36525 | .fn_ret_ty_ies = null, | 36492 | .fn_ret_ty_ies = null, |
| 36526 | .comptime_err_ret_trace = &comptime_err_ret_trace, | 36493 | .comptime_err_ret_trace = &comptime_err_ret_trace, |
| 36527 | }; | 36494 | }; |
| 36528 | defer sema.deinit(); | 36495 | defer inner_sema.deinit(); |
| 36529 | | 36496 | |
| 36530 | var block_scope: Block = .{ | 36497 | var block_scope: Block = .{ |
| 36531 | .parent = null, | 36498 | .parent = null, |
| 36532 | .sema = &sema, | 36499 | .sema = &inner_sema, |
| 36533 | .namespace = union_type.namespace, | 36500 | .namespace = union_type.namespace, |
| 36534 | .instructions = .{}, | 36501 | .instructions = .{}, |
| 36535 | .inlining = null, | 36502 | .inlining = null, |
| ... | @@ -36672,7 +36639,10 @@ fn semaUnionFields(pt: Zcu.PerThread, arena: Allocator, union_ty: InternPool.Ind | ... | @@ -36672,7 +36639,10 @@ fn semaUnionFields(pt: Zcu.PerThread, arena: Allocator, union_ty: InternPool.Ind |
| 36672 | | 36639 | |
| 36673 | if (enum_field_vals.capacity() > 0) { | 36640 | if (enum_field_vals.capacity() > 0) { |
| 36674 | const enum_tag_val = if (tag_ref != .none) blk: { | 36641 | const enum_tag_val = if (tag_ref != .none) blk: { |
| 36675 | const val = try sema.semaUnionFieldVal(&block_scope, value_src, int_tag_ty, tag_ref); | 36642 | const coerced = try sema.coerce(&block_scope, int_tag_ty, tag_ref, value_src); |
| | 36643 | const val = try sema.resolveConstDefinedValue(&block_scope, value_src, coerced, .{ |
| | 36644 | .needed_comptime_reason = "enum tag value must be comptime-known", |
| | 36645 | }); |
| 36676 | last_tag_val = val; | 36646 | last_tag_val = val; |
| 36677 | | 36647 | |
| 36678 | break :blk val; | 36648 | break :blk val; |
| ... | @@ -36692,7 +36662,11 @@ fn semaUnionFields(pt: Zcu.PerThread, arena: Allocator, union_ty: InternPool.Ind | ... | @@ -36692,7 +36662,11 @@ fn semaUnionFields(pt: Zcu.PerThread, arena: Allocator, union_ty: InternPool.Ind |
| 36692 | .offset = .{ .container_field_value = @intCast(gop.index) }, | 36662 | .offset = .{ .container_field_value = @intCast(gop.index) }, |
| 36693 | }; | 36663 | }; |
| 36694 | const msg = msg: { | 36664 | const msg = msg: { |
| 36695 | const msg = try sema.errMsg(value_src, "enum tag value {} already taken", .{enum_tag_val.fmtValueSema(pt, &sema)}); | 36665 | const msg = try sema.errMsg( |
| | 36666 | value_src, |
| | 36667 | "enum tag value {} already taken", |
| | 36668 | .{enum_tag_val.fmtValueSema(pt, sema)}, |
| | 36669 | ); |
| 36696 | errdefer msg.destroy(gpa); | 36670 | errdefer msg.destroy(gpa); |
| 36697 | try sema.errNote(other_value_src, msg, "other occurrence here", .{}); | 36671 | try sema.errNote(other_value_src, msg, "other occurrence here", .{}); |
| 36698 | break :msg msg; | 36672 | break :msg msg; |
| ... | @@ -36832,13 +36806,6 @@ fn semaUnionFields(pt: Zcu.PerThread, arena: Allocator, union_ty: InternPool.Ind | ... | @@ -36832,13 +36806,6 @@ fn semaUnionFields(pt: Zcu.PerThread, arena: Allocator, union_ty: InternPool.Ind |
| 36832 | try sema.flushExports(); | 36806 | try sema.flushExports(); |
| 36833 | } | 36807 | } |
| 36834 | | 36808 | |
| 36835 | fn semaUnionFieldVal(sema: *Sema, block: *Block, src: LazySrcLoc, int_tag_ty: Type, tag_ref: Air.Inst.Ref) CompileError!Value { | | |
| 36836 | const coerced = try sema.coerce(block, int_tag_ty, tag_ref, src); | | |
| 36837 | return sema.resolveConstDefinedValue(block, src, coerced, .{ | | |
| 36838 | .needed_comptime_reason = "enum tag value must be comptime-known", | | |
| 36839 | }); | | |
| 36840 | } | | |
| 36841 | | | |
| 36842 | fn generateUnionTagTypeNumbered( | 36809 | fn generateUnionTagTypeNumbered( |
| 36843 | sema: *Sema, | 36810 | sema: *Sema, |
| 36844 | block: *Block, | 36811 | block: *Block, |