| ... | @@ -7320,10 +7320,7 @@ fn callPanic( | ... | @@ -7320,10 +7320,7 @@ fn callPanic( |
| 7320 | return; | 7320 | return; |
| 7321 | } | 7321 | } |
| 7322 | const panic_cause_ty = try pt.getBuiltinType("PanicCause"); | 7322 | const panic_cause_ty = try pt.getBuiltinType("PanicCause"); |
| 7323 | const panic_cause = if (payload == .void_value) | 7323 | const panic_cause = try unionInitFromEnumTag(sema, block, call_src, panic_cause_ty, @intFromEnum(tag), payload); |
| 7324 | try initUnionFromEnumTag(pt, panic_cause_ty, panic_cause_ty.unionTagType(zcu).?, @intFromEnum(tag)) | | |
| 7325 | else | | |
| 7326 | try block.addUnionInit(panic_cause_ty, @intFromEnum(tag), payload); | | |
| 7327 | const panic_fn = try pt.getBuiltin("panic"); | 7324 | const panic_fn = try pt.getBuiltin("panic"); |
| 7328 | const err_return_trace = try sema.getErrorReturnTrace(block); | 7325 | const err_return_trace = try sema.getErrorReturnTrace(block); |
| 7329 | const opt_usize_ty = try pt.optionalType(.usize_type); | 7326 | const opt_usize_ty = try pt.optionalType(.usize_type); |
| ... | @@ -18311,7 +18308,8 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -18311,7 +18308,8 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18311 | .undefined, | 18308 | .undefined, |
| 18312 | .null, | 18309 | .null, |
| 18313 | .enum_literal, | 18310 | .enum_literal, |
| 18314 | => |type_info_tag| return initUnionFromEnumTag(pt, type_info_ty, type_info_tag_ty, @intFromEnum(type_info_tag)), | 18311 | => |type_info_tag| return unionInitFromEnumTag(sema, block, src, type_info_ty, @intFromEnum(type_info_tag), .void_value), |
| | 18312 | |
| 18315 | .@"fn" => { | 18313 | .@"fn" => { |
| 18316 | const fn_info_ty = try getInnerType(sema, block, src, type_info_ty, "Fn"); | 18314 | const fn_info_ty = try getInnerType(sema, block, src, type_info_ty, "Fn"); |
| 18317 | const param_info_ty = try getInnerType(sema, block, src, fn_info_ty, "Param"); | 18315 | const param_info_ty = try getInnerType(sema, block, src, fn_info_ty, "Param"); |
| ... | @@ -20607,6 +20605,20 @@ fn unionInit( | ... | @@ -20607,6 +20605,20 @@ fn unionInit( |
| 20607 | const field_index = try sema.unionFieldIndex(block, union_ty, field_name, field_src); | 20605 | const field_index = try sema.unionFieldIndex(block, union_ty, field_name, field_src); |
| 20608 | const field_ty = Type.fromInterned(zcu.typeToUnion(union_ty).?.field_types.get(ip)[field_index]); | 20606 | const field_ty = Type.fromInterned(zcu.typeToUnion(union_ty).?.field_types.get(ip)[field_index]); |
| 20609 | const init = try sema.coerce(block, field_ty, uncasted_init, init_src); | 20607 | const init = try sema.coerce(block, field_ty, uncasted_init, init_src); |
| | 20608 | _ = union_ty_src; |
| | 20609 | return unionInitFromEnumTag(sema, block, init_src, union_ty, field_index, init); |
| | 20610 | } |
| | 20611 | |
| | 20612 | fn unionInitFromEnumTag( |
| | 20613 | sema: *Sema, |
| | 20614 | block: *Block, |
| | 20615 | init_src: LazySrcLoc, |
| | 20616 | union_ty: Type, |
| | 20617 | field_index: u32, |
| | 20618 | init: Air.Inst.Ref, |
| | 20619 | ) !Air.Inst.Ref { |
| | 20620 | const pt = sema.pt; |
| | 20621 | const zcu = pt.zcu; |
| 20610 | | 20622 | |
| 20611 | if (try sema.resolveValue(init)) |init_val| { | 20623 | if (try sema.resolveValue(init)) |init_val| { |
| 20612 | const tag_ty = union_ty.unionTagTypeHypothetical(zcu); | 20624 | const tag_ty = union_ty.unionTagTypeHypothetical(zcu); |
| ... | @@ -20619,7 +20631,6 @@ fn unionInit( | ... | @@ -20619,7 +20631,6 @@ fn unionInit( |
| 20619 | } | 20631 | } |
| 20620 | | 20632 | |
| 20621 | try sema.requireRuntimeBlock(block, init_src, null); | 20633 | try sema.requireRuntimeBlock(block, init_src, null); |
| 20622 | _ = union_ty_src; | | |
| 20623 | return block.addUnionInit(union_ty, field_index, init); | 20634 | return block.addUnionInit(union_ty, field_index, init); |
| 20624 | } | 20635 | } |
| 20625 | | 20636 | |
| ... | @@ -38929,11 +38940,3 @@ fn getInnerType( | ... | @@ -38929,11 +38940,3 @@ fn getInnerType( |
| 38929 | try sema.ensureNavResolved(src, nav); | 38940 | try sema.ensureNavResolved(src, nav); |
| 38930 | return Type.fromInterned(ip.getNav(nav).status.resolved.val); | 38941 | return Type.fromInterned(ip.getNav(nav).status.resolved.val); |
| 38931 | } | 38942 | } |
| 38932 | | | |
| 38933 | fn initUnionFromEnumTag(pt: Zcu.PerThread, union_ty: Type, union_tag_ty: Type, field_index: u32) !Air.Inst.Ref { | | |
| 38934 | return Air.internedToRef((try pt.internUnion(.{ | | |
| 38935 | .ty = union_ty.toIntern(), | | |
| 38936 | .tag = (try pt.enumValueFieldIndex(union_tag_ty, field_index)).toIntern(), | | |
| 38937 | .val = .void_value, | | |
| 38938 | }))); | | |
| 38939 | } | | |