| ... | ... | @@ -18727,6 +18727,15 @@ fn zirUnionInit(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 18727 | 18727 | const init_src: LazySrcLoc = .{ .node_offset_builtin_call_arg2 = inst_data.src_node }; |
| 18728 | 18728 | const extra = sema.code.extraData(Zir.Inst.UnionInit, inst_data.payload_index).data; |
| 18729 | 18729 | const union_ty = try sema.resolveType(block, ty_src, extra.union_type); |
| 18730 | if (union_ty.zigTypeTag(sema.mod) != .Union) { |
| 18731 | const msg = msg: { |
| 18732 | const msg = try sema.errMsg(block, ty_src, "expected union type, found '{}'", .{union_ty.fmt(sema.mod)}); |
| 18733 | errdefer msg.destroy(sema.gpa); |
| 18734 | try sema.addDeclaredHereNote(msg, union_ty); |
| 18735 | break :msg msg; |
| 18736 | }; |
| 18737 | return sema.failWithOwnedErrorMsg(msg); |
| 18738 | } |
| 18730 | 18739 | const field_name = try sema.resolveConstStringIntern(block, field_src, extra.field_name, "name of field being initialized must be comptime-known"); |
| 18731 | 18740 | const init = try sema.resolveInst(extra.init); |
| 18732 | 18741 | return sema.unionInit(block, init, init_src, union_ty, ty_src, field_name, field_src); |