| ... | ... | @@ -1818,10 +1818,10 @@ fn failWithInvalidComptimeFieldStore(sema: *Sema, block: *Block, init_src: LazyS |
| 1818 | 1818 | |
| 1819 | 1819 | const tree = try sema.getAstTree(block); |
| 1820 | 1820 | const decl = sema.mod.declPtr(decl_index); |
| 1821 | | const field_src = enumFieldSrcLoc(decl, tree.*, container_ty.getNodeOffset(), field_index); |
| 1821 | const field_src = enumFieldSrcLoc(decl, tree.*, 0, field_index); |
| 1822 | 1822 | const default_value_src: LazySrcLoc = .{ .node_offset_field_default = field_src.node_offset.x }; |
| 1823 | 1823 | |
| 1824 | | try sema.errNote(block, default_value_src, msg, "default value set here", .{}); |
| 1824 | try sema.mod.errNoteNonLazy(default_value_src.toSrcLoc(decl), msg, "default value set here", .{}); |
| 1825 | 1825 | break :msg msg; |
| 1826 | 1826 | }; |
| 1827 | 1827 | return sema.failWithOwnedErrorMsg(msg); |
| ... | ... | @@ -1866,7 +1866,7 @@ fn addFieldErrNote( |
| 1866 | 1866 | const decl_index = container_ty.getOwnerDecl(); |
| 1867 | 1867 | const decl = mod.declPtr(decl_index); |
| 1868 | 1868 | const tree = try sema.getAstTree(block); |
| 1869 | | const field_src = enumFieldSrcLoc(decl, tree.*, container_ty.getNodeOffset(), field_index); |
| 1869 | const field_src = enumFieldSrcLoc(decl, tree.*, 0, field_index); |
| 1870 | 1870 | try mod.errNoteNonLazy(field_src.toSrcLoc(decl), parent, format, args); |
| 1871 | 1871 | } |
| 1872 | 1872 | |
| ... | ... | @@ -2262,7 +2262,7 @@ fn zirStructDecl( |
| 2262 | 2262 | const struct_obj = try new_decl_arena_allocator.create(Module.Struct); |
| 2263 | 2263 | const struct_ty = try Type.Tag.@"struct".create(new_decl_arena_allocator, struct_obj); |
| 2264 | 2264 | const struct_val = try Value.Tag.ty.create(new_decl_arena_allocator, struct_ty); |
| 2265 | | const new_decl_index = try sema.createAnonymousDeclTypeNamed(block, .{ |
| 2265 | const new_decl_index = try sema.createAnonymousDeclTypeNamed(block, src, .{ |
| 2266 | 2266 | .ty = Type.type, |
| 2267 | 2267 | .val = struct_val, |
| 2268 | 2268 | }, small.name_strategy, "struct", inst); |
| ... | ... | @@ -2272,7 +2272,6 @@ fn zirStructDecl( |
| 2272 | 2272 | struct_obj.* = .{ |
| 2273 | 2273 | .owner_decl = new_decl_index, |
| 2274 | 2274 | .fields = .{}, |
| 2275 | | .node_offset = src.node_offset.x, |
| 2276 | 2275 | .zir_index = inst, |
| 2277 | 2276 | .layout = small.layout, |
| 2278 | 2277 | .status = .none, |
| ... | ... | @@ -2294,6 +2293,7 @@ fn zirStructDecl( |
| 2294 | 2293 | fn createAnonymousDeclTypeNamed( |
| 2295 | 2294 | sema: *Sema, |
| 2296 | 2295 | block: *Block, |
| 2296 | src: LazySrcLoc, |
| 2297 | 2297 | typed_value: TypedValue, |
| 2298 | 2298 | name_strategy: Zir.Inst.NameStrategy, |
| 2299 | 2299 | anon_prefix: []const u8, |
| ... | ... | @@ -2303,7 +2303,8 @@ fn createAnonymousDeclTypeNamed( |
| 2303 | 2303 | const namespace = block.namespace; |
| 2304 | 2304 | const src_scope = block.wip_capture_scope; |
| 2305 | 2305 | const src_decl = mod.declPtr(block.src_decl); |
| 2306 | | const new_decl_index = try mod.allocateNewDecl(namespace, src_decl.src_node, src_scope); |
| 2306 | const src_node = src_decl.relativeToNodeIndex(src.node_offset.x); |
| 2307 | const new_decl_index = try mod.allocateNewDecl(namespace, src_node, src_scope); |
| 2307 | 2308 | errdefer mod.destroyDecl(new_decl_index); |
| 2308 | 2309 | |
| 2309 | 2310 | switch (name_strategy) { |
| ... | ... | @@ -2378,7 +2379,7 @@ fn createAnonymousDeclTypeNamed( |
| 2378 | 2379 | }, |
| 2379 | 2380 | else => {}, |
| 2380 | 2381 | }; |
| 2381 | | return sema.createAnonymousDeclTypeNamed(block, typed_value, .anon, anon_prefix, null); |
| 2382 | return sema.createAnonymousDeclTypeNamed(block, src, typed_value, .anon, anon_prefix, null); |
| 2382 | 2383 | }, |
| 2383 | 2384 | } |
| 2384 | 2385 | } |
| ... | ... | @@ -2442,7 +2443,7 @@ fn zirEnumDecl( |
| 2442 | 2443 | }; |
| 2443 | 2444 | const enum_ty = Type.initPayload(&enum_ty_payload.base); |
| 2444 | 2445 | const enum_val = try Value.Tag.ty.create(new_decl_arena_allocator, enum_ty); |
| 2445 | | const new_decl_index = try sema.createAnonymousDeclTypeNamed(block, .{ |
| 2446 | const new_decl_index = try sema.createAnonymousDeclTypeNamed(block, src, .{ |
| 2446 | 2447 | .ty = Type.type, |
| 2447 | 2448 | .val = enum_val, |
| 2448 | 2449 | }, small.name_strategy, "enum", inst); |
| ... | ... | @@ -2456,7 +2457,6 @@ fn zirEnumDecl( |
| 2456 | 2457 | .tag_ty_inferred = true, |
| 2457 | 2458 | .fields = .{}, |
| 2458 | 2459 | .values = .{}, |
| 2459 | | .node_offset = src.node_offset.x, |
| 2460 | 2460 | .namespace = .{ |
| 2461 | 2461 | .parent = block.namespace, |
| 2462 | 2462 | .ty = enum_ty, |
| ... | ... | @@ -2684,7 +2684,7 @@ fn zirUnionDecl( |
| 2684 | 2684 | const union_ty = Type.initPayload(&union_payload.base); |
| 2685 | 2685 | const union_val = try Value.Tag.ty.create(new_decl_arena_allocator, union_ty); |
| 2686 | 2686 | const mod = sema.mod; |
| 2687 | | const new_decl_index = try sema.createAnonymousDeclTypeNamed(block, .{ |
| 2687 | const new_decl_index = try sema.createAnonymousDeclTypeNamed(block, src, .{ |
| 2688 | 2688 | .ty = Type.type, |
| 2689 | 2689 | .val = union_val, |
| 2690 | 2690 | }, small.name_strategy, "union", inst); |
| ... | ... | @@ -2695,7 +2695,6 @@ fn zirUnionDecl( |
| 2695 | 2695 | .owner_decl = new_decl_index, |
| 2696 | 2696 | .tag_ty = Type.initTag(.@"null"), |
| 2697 | 2697 | .fields = .{}, |
| 2698 | | .node_offset = src.node_offset.x, |
| 2699 | 2698 | .zir_index = inst, |
| 2700 | 2699 | .layout = small.layout, |
| 2701 | 2700 | .status = .none, |
| ... | ... | @@ -2753,7 +2752,7 @@ fn zirOpaqueDecl( |
| 2753 | 2752 | }; |
| 2754 | 2753 | const opaque_ty = Type.initPayload(&opaque_ty_payload.base); |
| 2755 | 2754 | const opaque_val = try Value.Tag.ty.create(new_decl_arena_allocator, opaque_ty); |
| 2756 | | const new_decl_index = try sema.createAnonymousDeclTypeNamed(block, .{ |
| 2755 | const new_decl_index = try sema.createAnonymousDeclTypeNamed(block, src, .{ |
| 2757 | 2756 | .ty = Type.type, |
| 2758 | 2757 | .val = opaque_val, |
| 2759 | 2758 | }, small.name_strategy, "opaque", inst); |
| ... | ... | @@ -2763,7 +2762,6 @@ fn zirOpaqueDecl( |
| 2763 | 2762 | |
| 2764 | 2763 | opaque_obj.* = .{ |
| 2765 | 2764 | .owner_decl = new_decl_index, |
| 2766 | | .node_offset = src.node_offset.x, |
| 2767 | 2765 | .namespace = .{ |
| 2768 | 2766 | .parent = block.namespace, |
| 2769 | 2767 | .ty = opaque_ty, |
| ... | ... | @@ -2802,7 +2800,7 @@ fn zirErrorSetDecl( |
| 2802 | 2800 | const error_set_ty = try Type.Tag.error_set.create(new_decl_arena_allocator, error_set); |
| 2803 | 2801 | const error_set_val = try Value.Tag.ty.create(new_decl_arena_allocator, error_set_ty); |
| 2804 | 2802 | const mod = sema.mod; |
| 2805 | | const new_decl_index = try sema.createAnonymousDeclTypeNamed(block, .{ |
| 2803 | const new_decl_index = try sema.createAnonymousDeclTypeNamed(block, src, .{ |
| 2806 | 2804 | .ty = Type.type, |
| 2807 | 2805 | .val = error_set_val, |
| 2808 | 2806 | }, name_strategy, "error", inst); |
| ... | ... | @@ -2827,7 +2825,6 @@ fn zirErrorSetDecl( |
| 2827 | 2825 | |
| 2828 | 2826 | error_set.* = .{ |
| 2829 | 2827 | .owner_decl = new_decl_index, |
| 2830 | | .node_offset = inst_data.src_node, |
| 2831 | 2828 | .names = names, |
| 2832 | 2829 | }; |
| 2833 | 2830 | try new_decl.finalizeNewArena(&new_decl_arena); |
| ... | ... | @@ -16336,7 +16333,7 @@ fn zirReify(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData, in |
| 16336 | 16333 | }; |
| 16337 | 16334 | const enum_ty = Type.initPayload(&enum_ty_payload.base); |
| 16338 | 16335 | const enum_val = try Value.Tag.ty.create(new_decl_arena_allocator, enum_ty); |
| 16339 | | const new_decl_index = try sema.createAnonymousDeclTypeNamed(block, .{ |
| 16336 | const new_decl_index = try sema.createAnonymousDeclTypeNamed(block, src, .{ |
| 16340 | 16337 | .ty = Type.type, |
| 16341 | 16338 | .val = enum_val, |
| 16342 | 16339 | }, name_strategy, "enum", inst); |
| ... | ... | @@ -16350,7 +16347,6 @@ fn zirReify(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData, in |
| 16350 | 16347 | .tag_ty_inferred = false, |
| 16351 | 16348 | .fields = .{}, |
| 16352 | 16349 | .values = .{}, |
| 16353 | | .node_offset = src.node_offset.x, |
| 16354 | 16350 | .namespace = .{ |
| 16355 | 16351 | .parent = block.namespace, |
| 16356 | 16352 | .ty = enum_ty, |
| ... | ... | @@ -16433,7 +16429,7 @@ fn zirReify(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData, in |
| 16433 | 16429 | }; |
| 16434 | 16430 | const opaque_ty = Type.initPayload(&opaque_ty_payload.base); |
| 16435 | 16431 | const opaque_val = try Value.Tag.ty.create(new_decl_arena_allocator, opaque_ty); |
| 16436 | | const new_decl_index = try sema.createAnonymousDeclTypeNamed(block, .{ |
| 16432 | const new_decl_index = try sema.createAnonymousDeclTypeNamed(block, src, .{ |
| 16437 | 16433 | .ty = Type.type, |
| 16438 | 16434 | .val = opaque_val, |
| 16439 | 16435 | }, name_strategy, "opaque", inst); |
| ... | ... | @@ -16443,7 +16439,6 @@ fn zirReify(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData, in |
| 16443 | 16439 | |
| 16444 | 16440 | opaque_obj.* = .{ |
| 16445 | 16441 | .owner_decl = new_decl_index, |
| 16446 | | .node_offset = src.node_offset.x, |
| 16447 | 16442 | .namespace = .{ |
| 16448 | 16443 | .parent = block.namespace, |
| 16449 | 16444 | .ty = opaque_ty, |
| ... | ... | @@ -16492,7 +16487,7 @@ fn zirReify(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData, in |
| 16492 | 16487 | }; |
| 16493 | 16488 | const union_ty = Type.initPayload(&union_payload.base); |
| 16494 | 16489 | const new_union_val = try Value.Tag.ty.create(new_decl_arena_allocator, union_ty); |
| 16495 | | const new_decl_index = try sema.createAnonymousDeclTypeNamed(block, .{ |
| 16490 | const new_decl_index = try sema.createAnonymousDeclTypeNamed(block, src, .{ |
| 16496 | 16491 | .ty = Type.type, |
| 16497 | 16492 | .val = new_union_val, |
| 16498 | 16493 | }, name_strategy, "union", inst); |
| ... | ... | @@ -16503,7 +16498,6 @@ fn zirReify(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData, in |
| 16503 | 16498 | .owner_decl = new_decl_index, |
| 16504 | 16499 | .tag_ty = Type.initTag(.@"null"), |
| 16505 | 16500 | .fields = .{}, |
| 16506 | | .node_offset = src.node_offset.x, |
| 16507 | 16501 | .zir_index = inst, |
| 16508 | 16502 | .layout = layout, |
| 16509 | 16503 | .status = .have_field_types, |
| ... | ... | @@ -16798,7 +16792,7 @@ fn reifyStruct( |
| 16798 | 16792 | const struct_ty = try Type.Tag.@"struct".create(new_decl_arena_allocator, struct_obj); |
| 16799 | 16793 | const new_struct_val = try Value.Tag.ty.create(new_decl_arena_allocator, struct_ty); |
| 16800 | 16794 | const mod = sema.mod; |
| 16801 | | const new_decl_index = try sema.createAnonymousDeclTypeNamed(block, .{ |
| 16795 | const new_decl_index = try sema.createAnonymousDeclTypeNamed(block, src, .{ |
| 16802 | 16796 | .ty = Type.type, |
| 16803 | 16797 | .val = new_struct_val, |
| 16804 | 16798 | }, name_strategy, "struct", inst); |
| ... | ... | @@ -16808,7 +16802,6 @@ fn reifyStruct( |
| 16808 | 16802 | struct_obj.* = .{ |
| 16809 | 16803 | .owner_decl = new_decl_index, |
| 16810 | 16804 | .fields = .{}, |
| 16811 | | .node_offset = src.node_offset.x, |
| 16812 | 16805 | .zir_index = inst, |
| 16813 | 16806 | .layout = layout_val.toEnum(std.builtin.Type.ContainerLayout), |
| 16814 | 16807 | .status = .have_field_types, |
| ... | ... | @@ -27241,7 +27234,7 @@ fn semaStructFields(mod: *Module, struct_obj: *Module.Struct) CompileError!void |
| 27241 | 27234 | const small = @bitCast(Zir.Inst.StructDecl.Small, extended.small); |
| 27242 | 27235 | var extra_index: usize = extended.operand; |
| 27243 | 27236 | |
| 27244 | | const src = LazySrcLoc.nodeOffset(struct_obj.node_offset); |
| 27237 | const src = LazySrcLoc.nodeOffset(0); |
| 27245 | 27238 | extra_index += @boolToInt(small.has_src_node); |
| 27246 | 27239 | |
| 27247 | 27240 | const fields_len = if (small.has_fields_len) blk: { |
| ... | ... | @@ -27360,12 +27353,12 @@ fn semaStructFields(mod: *Module, struct_obj: *Module.Struct) CompileError!void |
| 27360 | 27353 | if (gop.found_existing) { |
| 27361 | 27354 | const msg = msg: { |
| 27362 | 27355 | const tree = try sema.getAstTree(&block_scope); |
| 27363 | | const field_src = enumFieldSrcLoc(decl, tree.*, struct_obj.node_offset, field_i); |
| 27356 | const field_src = enumFieldSrcLoc(decl, tree.*, 0, field_i); |
| 27364 | 27357 | const msg = try sema.errMsg(&block_scope, field_src, "duplicate struct field: '{s}'", .{field_name}); |
| 27365 | 27358 | errdefer msg.destroy(gpa); |
| 27366 | 27359 | |
| 27367 | 27360 | const prev_field_index = struct_obj.fields.getIndex(field_name).?; |
| 27368 | | const prev_field_src = enumFieldSrcLoc(decl, tree.*, struct_obj.node_offset, prev_field_index); |
| 27361 | const prev_field_src = enumFieldSrcLoc(decl, tree.*, 0, prev_field_index); |
| 27369 | 27362 | try sema.mod.errNoteNonLazy(prev_field_src.toSrcLoc(decl), msg, "other field here", .{}); |
| 27370 | 27363 | try sema.errNote(&block_scope, src, msg, "struct declared here", .{}); |
| 27371 | 27364 | break :msg msg; |
| ... | ... | @@ -27422,7 +27415,7 @@ fn semaStructFields(mod: *Module, struct_obj: *Module.Struct) CompileError!void |
| 27422 | 27415 | if (field_ty.zigTypeTag() == .Opaque) { |
| 27423 | 27416 | const msg = msg: { |
| 27424 | 27417 | const tree = try sema.getAstTree(&block_scope); |
| 27425 | | const field_src = enumFieldSrcLoc(decl, tree.*, struct_obj.node_offset, i); |
| 27418 | const field_src = enumFieldSrcLoc(decl, tree.*, 0, i); |
| 27426 | 27419 | const msg = try sema.errMsg(&block_scope, field_src, "opaque types have unknown size and therefore cannot be directly embedded in structs", .{}); |
| 27427 | 27420 | errdefer msg.destroy(sema.gpa); |
| 27428 | 27421 | |
| ... | ... | @@ -27434,7 +27427,7 @@ fn semaStructFields(mod: *Module, struct_obj: *Module.Struct) CompileError!void |
| 27434 | 27427 | if (struct_obj.layout == .Extern and !sema.validateExternType(field.ty, .other)) { |
| 27435 | 27428 | const msg = msg: { |
| 27436 | 27429 | const tree = try sema.getAstTree(&block_scope); |
| 27437 | | const fields_src = enumFieldSrcLoc(decl, tree.*, struct_obj.node_offset, i); |
| 27430 | const fields_src = enumFieldSrcLoc(decl, tree.*, 0, i); |
| 27438 | 27431 | const msg = try sema.errMsg(&block_scope, fields_src, "extern structs cannot contain fields of type '{}'", .{field.ty.fmt(sema.mod)}); |
| 27439 | 27432 | errdefer msg.destroy(sema.gpa); |
| 27440 | 27433 | |
| ... | ... | @@ -27447,7 +27440,7 @@ fn semaStructFields(mod: *Module, struct_obj: *Module.Struct) CompileError!void |
| 27447 | 27440 | } else if (struct_obj.layout == .Packed and !(validatePackedType(field.ty))) { |
| 27448 | 27441 | const msg = msg: { |
| 27449 | 27442 | const tree = try sema.getAstTree(&block_scope); |
| 27450 | | const fields_src = enumFieldSrcLoc(decl, tree.*, struct_obj.node_offset, i); |
| 27443 | const fields_src = enumFieldSrcLoc(decl, tree.*, 0, i); |
| 27451 | 27444 | const msg = try sema.errMsg(&block_scope, fields_src, "packed structs cannot contain fields of type '{}'", .{field.ty.fmt(sema.mod)}); |
| 27452 | 27445 | errdefer msg.destroy(sema.gpa); |
| 27453 | 27446 | |
| ... | ... | @@ -27504,7 +27497,7 @@ fn semaUnionFields(mod: *Module, union_obj: *Module.Union) CompileError!void { |
| 27504 | 27497 | const small = @bitCast(Zir.Inst.UnionDecl.Small, extended.small); |
| 27505 | 27498 | var extra_index: usize = extended.operand; |
| 27506 | 27499 | |
| 27507 | | const src = LazySrcLoc.nodeOffset(union_obj.node_offset); |
| 27500 | const src = LazySrcLoc.nodeOffset(0); |
| 27508 | 27501 | extra_index += @boolToInt(small.has_src_node); |
| 27509 | 27502 | |
| 27510 | 27503 | const tag_type_ref: Zir.Inst.Ref = if (small.has_tag_type) blk: { |
| ... | ... | @@ -27728,12 +27721,12 @@ fn semaUnionFields(mod: *Module, union_obj: *Module.Union) CompileError!void { |
| 27728 | 27721 | if (gop.found_existing) { |
| 27729 | 27722 | const msg = msg: { |
| 27730 | 27723 | const tree = try sema.getAstTree(&block_scope); |
| 27731 | | const field_src = enumFieldSrcLoc(decl, tree.*, union_obj.node_offset, field_i); |
| 27724 | const field_src = enumFieldSrcLoc(decl, tree.*, 0, field_i); |
| 27732 | 27725 | const msg = try sema.errMsg(&block_scope, field_src, "duplicate union field: '{s}'", .{field_name}); |
| 27733 | 27726 | errdefer msg.destroy(gpa); |
| 27734 | 27727 | |
| 27735 | 27728 | const prev_field_index = union_obj.fields.getIndex(field_name).?; |
| 27736 | | const prev_field_src = enumFieldSrcLoc(decl, tree.*, union_obj.node_offset, prev_field_index); |
| 27729 | const prev_field_src = enumFieldSrcLoc(decl, tree.*, 0, prev_field_index); |
| 27737 | 27730 | try sema.mod.errNoteNonLazy(prev_field_src.toSrcLoc(decl), msg, "other field here", .{}); |
| 27738 | 27731 | try sema.errNote(&block_scope, src, msg, "union declared here", .{}); |
| 27739 | 27732 | break :msg msg; |
| ... | ... | @@ -27746,7 +27739,7 @@ fn semaUnionFields(mod: *Module, union_obj: *Module.Union) CompileError!void { |
| 27746 | 27739 | if (!enum_has_field) { |
| 27747 | 27740 | const msg = msg: { |
| 27748 | 27741 | const tree = try sema.getAstTree(&block_scope); |
| 27749 | | const field_src = enumFieldSrcLoc(decl, tree.*, union_obj.node_offset, field_i); |
| 27742 | const field_src = enumFieldSrcLoc(decl, tree.*, 0, field_i); |
| 27750 | 27743 | const msg = try sema.errMsg(&block_scope, field_src, "no field named '{s}' in enum '{}'", .{ field_name, union_obj.tag_ty.fmt(sema.mod) }); |
| 27751 | 27744 | errdefer msg.destroy(sema.gpa); |
| 27752 | 27745 | try sema.addDeclaredHereNote(msg, union_obj.tag_ty); |
| ... | ... | @@ -27759,7 +27752,7 @@ fn semaUnionFields(mod: *Module, union_obj: *Module.Union) CompileError!void { |
| 27759 | 27752 | if (field_ty.zigTypeTag() == .Opaque) { |
| 27760 | 27753 | const msg = msg: { |
| 27761 | 27754 | const tree = try sema.getAstTree(&block_scope); |
| 27762 | | const field_src = enumFieldSrcLoc(decl, tree.*, union_obj.node_offset, field_i); |
| 27755 | const field_src = enumFieldSrcLoc(decl, tree.*, 0, field_i); |
| 27763 | 27756 | const msg = try sema.errMsg(&block_scope, field_src, "opaque types have unknown size and therefore cannot be directly embedded in unions", .{}); |
| 27764 | 27757 | errdefer msg.destroy(sema.gpa); |
| 27765 | 27758 | |
| ... | ... | @@ -27771,7 +27764,7 @@ fn semaUnionFields(mod: *Module, union_obj: *Module.Union) CompileError!void { |
| 27771 | 27764 | if (union_obj.layout == .Extern and !sema.validateExternType(field_ty, .union_field)) { |
| 27772 | 27765 | const msg = msg: { |
| 27773 | 27766 | const tree = try sema.getAstTree(&block_scope); |
| 27774 | | const field_src = enumFieldSrcLoc(decl, tree.*, union_obj.node_offset, field_i); |
| 27767 | const field_src = enumFieldSrcLoc(decl, tree.*, 0, field_i); |
| 27775 | 27768 | const msg = try sema.errMsg(&block_scope, field_src, "extern unions cannot contain fields of type '{}'", .{field_ty.fmt(sema.mod)}); |
| 27776 | 27769 | errdefer msg.destroy(sema.gpa); |
| 27777 | 27770 | |
| ... | ... | @@ -27784,7 +27777,7 @@ fn semaUnionFields(mod: *Module, union_obj: *Module.Union) CompileError!void { |
| 27784 | 27777 | } else if (union_obj.layout == .Packed and !(validatePackedType(field_ty))) { |
| 27785 | 27778 | const msg = msg: { |
| 27786 | 27779 | const tree = try sema.getAstTree(&block_scope); |
| 27787 | | const fields_src = enumFieldSrcLoc(decl, tree.*, union_obj.node_offset, field_i); |
| 27780 | const fields_src = enumFieldSrcLoc(decl, tree.*, 0, field_i); |
| 27788 | 27781 | const msg = try sema.errMsg(&block_scope, fields_src, "packed unions cannot contain fields of type '{}'", .{field_ty.fmt(sema.mod)}); |
| 27789 | 27782 | errdefer msg.destroy(sema.gpa); |
| 27790 | 27783 | |
| ... | ... | @@ -27876,7 +27869,6 @@ fn generateUnionTagTypeNumbered( |
| 27876 | 27869 | .tag_ty = int_ty, |
| 27877 | 27870 | .fields = .{}, |
| 27878 | 27871 | .values = .{}, |
| 27879 | | .node_offset = 0, |
| 27880 | 27872 | }; |
| 27881 | 27873 | // Here we pre-allocate the maps using the decl arena. |
| 27882 | 27874 | try enum_obj.fields.ensureTotalCapacity(new_decl_arena_allocator, fields_len); |
| ... | ... | @@ -27934,7 +27926,6 @@ fn generateUnionTagTypeSimple(sema: *Sema, block: *Block, fields_len: usize, may |
| 27934 | 27926 | enum_obj.* = .{ |
| 27935 | 27927 | .owner_decl = new_decl_index, |
| 27936 | 27928 | .fields = .{}, |
| 27937 | | .node_offset = 0, |
| 27938 | 27929 | }; |
| 27939 | 27930 | // Here we pre-allocate the maps using the decl arena. |
| 27940 | 27931 | try enum_obj.fields.ensureTotalCapacity(new_decl_arena_allocator, fields_len); |
| ... | ... | @@ -28245,7 +28236,7 @@ fn enumFieldSrcLoc( |
| 28245 | 28236 | => tree.containerDeclArg(enum_node), |
| 28246 | 28237 | |
| 28247 | 28238 | // Container was constructed with `@Type`. |
| 28248 | | else => return LazySrcLoc.nodeOffset(node_offset), |
| 28239 | else => return LazySrcLoc.nodeOffset(0), |
| 28249 | 28240 | }; |
| 28250 | 28241 | var it_index: usize = 0; |
| 28251 | 28242 | for (container_decl.ast.members) |member_node| { |