| ... | @@ -7617,11 +7617,11 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -7617,11 +7617,11 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 7617 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 7617 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 7618 | | 7618 | |
| 7619 | const dest_ty = try sema.resolveType(block, dest_ty_src, extra.lhs); | 7619 | const dest_ty = try sema.resolveType(block, dest_ty_src, extra.lhs); |
| | 7620 | const operand = try sema.resolveInst(extra.rhs); |
| 7620 | switch (dest_ty.zigTypeTag()) { | 7621 | switch (dest_ty.zigTypeTag()) { |
| 7621 | .AnyFrame, | 7622 | .AnyFrame, |
| 7622 | .ComptimeFloat, | 7623 | .ComptimeFloat, |
| 7623 | .ComptimeInt, | 7624 | .ComptimeInt, |
| 7624 | .Enum, | | |
| 7625 | .EnumLiteral, | 7625 | .EnumLiteral, |
| 7626 | .ErrorSet, | 7626 | .ErrorSet, |
| 7627 | .ErrorUnion, | 7627 | .ErrorUnion, |
| ... | @@ -7634,7 +7634,21 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -7634,7 +7634,21 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 7634 | .Type, | 7634 | .Type, |
| 7635 | .Undefined, | 7635 | .Undefined, |
| 7636 | .Void, | 7636 | .Void, |
| 7637 | => return sema.fail(block, dest_ty_src, "invalid type '{}' for @bitCast", .{dest_ty.fmt(sema.mod)}), | 7637 | => return sema.fail(block, dest_ty_src, "cannot @bitCast to '{}'", .{dest_ty.fmt(sema.mod)}), |
| | 7638 | |
| | 7639 | .Enum => { |
| | 7640 | const msg = msg: { |
| | 7641 | const msg = try sema.errMsg(block, dest_ty_src, "cannot @bitCast to '{}'", .{dest_ty.fmt(sema.mod)}); |
| | 7642 | errdefer msg.destroy(sema.gpa); |
| | 7643 | switch (sema.typeOf(operand).zigTypeTag()) { |
| | 7644 | .Int, .ComptimeInt => try sema.errNote(block, dest_ty_src, msg, "use @intToEnum for type coercion", .{}), |
| | 7645 | else => {}, |
| | 7646 | } |
| | 7647 | |
| | 7648 | break :msg msg; |
| | 7649 | }; |
| | 7650 | return sema.failWithOwnedErrorMsg(block, msg); |
| | 7651 | }, |
| 7638 | | 7652 | |
| 7639 | .Pointer => return sema.fail(block, dest_ty_src, "cannot @bitCast to '{}', use @ptrCast to cast to a pointer", .{ | 7653 | .Pointer => return sema.fail(block, dest_ty_src, "cannot @bitCast to '{}', use @ptrCast to cast to a pointer", .{ |
| 7640 | dest_ty.fmt(sema.mod), | 7654 | dest_ty.fmt(sema.mod), |
| ... | @@ -7658,8 +7672,6 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -7658,8 +7672,6 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 7658 | .Vector, | 7672 | .Vector, |
| 7659 | => {}, | 7673 | => {}, |
| 7660 | } | 7674 | } |
| 7661 | | | |
| 7662 | const operand = try sema.resolveInst(extra.rhs); | | |
| 7663 | return sema.bitCast(block, dest_ty, operand, operand_src); | 7675 | return sema.bitCast(block, dest_ty, operand, operand_src); |
| 7664 | } | 7676 | } |
| 7665 | | 7677 | |