| ... | @@ -20411,7 +20411,7 @@ fn coerceExtra( | ... | @@ -20411,7 +20411,7 @@ fn coerceExtra( |
| 20411 | const InMemoryCoercionResult = union(enum) { | 20411 | const InMemoryCoercionResult = union(enum) { |
| 20412 | ok, | 20412 | ok, |
| 20413 | no_match: Pair, | 20413 | no_match: Pair, |
| 20414 | int_mismatch: Int, | 20414 | int_not_coercible: Int, |
| 20415 | error_union_payload: PairAndChild, | 20415 | error_union_payload: PairAndChild, |
| 20416 | array_len: IntPair, | 20416 | array_len: IntPair, |
| 20417 | array_sentinel: Sentinel, | 20417 | array_sentinel: Sentinel, |
| ... | @@ -20527,7 +20527,7 @@ const InMemoryCoercionResult = union(enum) { | ... | @@ -20527,7 +20527,7 @@ const InMemoryCoercionResult = union(enum) { |
| 20527 | try sema.addDeclaredHereNote(msg, types.actual); | 20527 | try sema.addDeclaredHereNote(msg, types.actual); |
| 20528 | break; | 20528 | break; |
| 20529 | }, | 20529 | }, |
| 20530 | .int_mismatch => |int| { | 20530 | .int_not_coercible => |int| { |
| 20531 | try sema.errNote(block, src, msg, "{s} {d}-bit int cannot represent all possible {s} {d}-bit values", .{ | 20531 | try sema.errNote(block, src, msg, "{s} {d}-bit int cannot represent all possible {s} {d}-bit values", .{ |
| 20532 | @tagName(int.wanted_signedness), int.wanted_bits, @tagName(int.actual_signedness), int.actual_bits, | 20532 | @tagName(int.wanted_signedness), int.wanted_bits, @tagName(int.actual_signedness), int.actual_bits, |
| 20533 | }); | 20533 | }); |
| ... | @@ -20768,17 +20768,25 @@ fn coerceInMemoryAllowed( | ... | @@ -20768,17 +20768,25 @@ fn coerceInMemoryAllowed( |
| 20768 | if (dest_ty.zigTypeTag() == .Int and src_ty.zigTypeTag() == .Int) { | 20768 | if (dest_ty.zigTypeTag() == .Int and src_ty.zigTypeTag() == .Int) { |
| 20769 | const dest_info = dest_ty.intInfo(target); | 20769 | const dest_info = dest_ty.intInfo(target); |
| 20770 | const src_info = src_ty.intInfo(target); | 20770 | const src_info = src_ty.intInfo(target); |
| 20771 | if (dest_info.signedness != src_info.signedness or | 20771 | |
| 20772 | dest_info.bits != src_info.bits) | 20772 | if (dest_info.signedness == src_info.signedness and |
| | 20773 | dest_info.bits == src_info.bits) |
| | 20774 | { |
| | 20775 | return .ok; |
| | 20776 | } |
| | 20777 | |
| | 20778 | if ((src_info.signedness == dest_info.signedness and dest_info.bits < src_info.bits) or |
| | 20779 | // small enough unsigned ints can get casted to large enough signed ints |
| | 20780 | (dest_info.signedness == .signed and (src_info.signedness == .unsigned or dest_info.bits <= src_info.bits)) or |
| | 20781 | (dest_info.signedness == .unsigned and src_info.signedness == .signed)) |
| 20773 | { | 20782 | { |
| 20774 | return InMemoryCoercionResult{ .int_mismatch = .{ | 20783 | return InMemoryCoercionResult{ .int_not_coercible = .{ |
| 20775 | .actual_signedness = src_info.signedness, | 20784 | .actual_signedness = src_info.signedness, |
| 20776 | .wanted_signedness = dest_info.signedness, | 20785 | .wanted_signedness = dest_info.signedness, |
| 20777 | .actual_bits = src_info.bits, | 20786 | .actual_bits = src_info.bits, |
| 20778 | .wanted_bits = dest_info.bits, | 20787 | .wanted_bits = dest_info.bits, |
| 20779 | } }; | 20788 | } }; |
| 20780 | } | 20789 | } |
| 20781 | return .ok; | | |
| 20782 | } | 20790 | } |
| 20783 | | 20791 | |
| 20784 | // Differently-named floats with the same number of bits. | 20792 | // Differently-named floats with the same number of bits. |