| author | |
| committer | |
| log | 83a3365bfd9dc17067de26b3cb4c9af55a34644e |
| tree | ba0ed0fc4655b23dc26eb7bd87da0745ef0dc675 |
| parent | 05b7ca6356e4f394c084de8e806c1c93440e0b6b |
| signature |
Resolves: #252212 files changed, 10 insertions(+), 4 deletions(-)
lib/std/math/big/int.zig+3-4| ... | ... | @@ -786,11 +786,10 @@ pub const Mutable = struct { |
| 786 | 786 | assert(rma.limbs.ptr != b.limbs.ptr); // illegal aliasing |
| 787 | 787 | |
| 788 | 788 | if (a.limbs.len == 1 and b.limbs.len == 1) { |
| 789 | const ov = @mulWithOverflow(a.limbs[0], b.limbs[0]); | |
| 790 | rma.limbs[0] = ov[0]; | |
| 791 | if (ov[1] == 0) { | |
| 789 | rma.limbs[0], const overflow_bit = @mulWithOverflow(a.limbs[0], b.limbs[0]); | |
| 790 | if (overflow_bit == 0) { | |
| 792 | 791 | rma.len = 1; |
| 793 | rma.positive = (a.positive == b.positive); | |
| 792 | rma.positive = (a.positive == b.positive) or rma.limbs[0] == 0; | |
| 794 | 793 | return; |
| 795 | 794 | } |
| 796 | 795 | } |
test/behavior/enum.zig+7| ... | ... | @@ -1325,3 +1325,10 @@ test "large enum field values" { |
| 1325 | 1325 | try expect(@intFromEnum(e) == std.math.maxInt(i128)); |
| 1326 | 1326 | } |
| 1327 | 1327 | } |
| 1328 | ||
| 1329 | test "comptime @enumFromInt with signed arithmetic" { | |
| 1330 | const E = enum(i8) { foo = -1, bar = 0 }; | |
| 1331 | const x: E = @enumFromInt(@as(i8, -1) * 0); | |
| 1332 | comptime assert(x == .bar); | |
| 1333 | comptime assert(@intFromEnum(x) == 0); | |
| 1334 | } |