| ... | @@ -705,34 +705,34 @@ pub fn Vector(comptime len: u32, comptime child: type) type { | ... | @@ -705,34 +705,34 @@ pub fn Vector(comptime len: u32, comptime child: type) type { |
| 705 | pub fn cast(comptime DestType: type, target: anytype) DestType { | 705 | pub fn cast(comptime DestType: type, target: anytype) DestType { |
| 706 | const TargetType = @TypeOf(target); | 706 | const TargetType = @TypeOf(target); |
| 707 | switch (@typeInfo(DestType)) { | 707 | switch (@typeInfo(DestType)) { |
| 708 | .Pointer => { | 708 | .Pointer => |dest_ptr| { |
| 709 | switch (@typeInfo(TargetType)) { | 709 | switch (@typeInfo(TargetType)) { |
| 710 | .Int, .ComptimeInt => { | 710 | .Int, .ComptimeInt => { |
| 711 | return @intToPtr(DestType, target); | 711 | return @intToPtr(DestType, target); |
| 712 | }, | 712 | }, |
| 713 | .Pointer => |ptr| { | 713 | .Pointer => |ptr| { |
| 714 | return @ptrCast(DestType, @alignCast(ptr.alignment, target)); | 714 | return @ptrCast(DestType, @alignCast(dest_ptr.alignment, target)); |
| 715 | }, | 715 | }, |
| 716 | .Optional => |opt| { | 716 | .Optional => |opt| { |
| 717 | if (@typeInfo(opt.child) == .Pointer) { | 717 | if (@typeInfo(opt.child) == .Pointer) { |
| 718 | return @ptrCast(DestType, @alignCast(@alignOf(opt.child.Child), target)); | 718 | return @ptrCast(DestType, @alignCast(dest_ptr, target)); |
| 719 | } | 719 | } |
| 720 | }, | 720 | }, |
| 721 | else => {}, | 721 | else => {}, |
| 722 | } | 722 | } |
| 723 | }, | 723 | }, |
| 724 | .Optional => |opt| { | 724 | .Optional => |dest_opt| { |
| 725 | if (@typeInfo(opt.child) == .Pointer) { | 725 | if (@typeInfo(dest_opt.child) == .Pointer) { |
| 726 | switch (@typeInfo(TargetType)) { | 726 | switch (@typeInfo(TargetType)) { |
| 727 | .Int, .ComptimeInt => { | 727 | .Int, .ComptimeInt => { |
| 728 | return @intToPtr(DestType, target); | 728 | return @intToPtr(DestType, target); |
| 729 | }, | 729 | }, |
| 730 | .Pointer => |ptr| { | 730 | .Pointer => { |
| 731 | return @ptrCast(DestType, @alignCast(ptr.alignment, target)); | 731 | return @ptrCast(DestType, @alignCast(@alignOf(dest_opt.child.Child), target)); |
| 732 | }, | 732 | }, |
| 733 | .Optional => |target_opt| { | 733 | .Optional => |target_opt| { |
| 734 | if (@typeInfo(target_opt.child) == .Pointer) { | 734 | if (@typeInfo(target_opt.child) == .Pointer) { |
| 735 | return @ptrCast(DestType, @alignCast(@alignOf(target_opt.child.Child), target)); | 735 | return @ptrCast(DestType, @alignCast(@alignOf(dest_opt.child.Child), target)); |
| 736 | } | 736 | } |
| 737 | }, | 737 | }, |
| 738 | else => {}, | 738 | else => {}, |