| author | |
| committer | |
| log | 47dd1049c8ef4064084af05e7b62becf502e41e6 |
| tree | ac9e77d8b76f5733c3309f4f0dbc83b0246c75b7 |
| parent | f50c0c664f3bd7a56c0274ffecae28e2b41c8d20 |
| parent | f1207a8e744617d62e5c535cf05764cdf2cfd99e |
| signature |
Fix bigint -1 increment operation3 files changed, 22 insertions(+), 4 deletions(-)
src/bigint.cpp+9-4| ... | @@ -1683,10 +1683,15 @@ void bigint_incr(BigInt *x) { | ... | @@ -1683,10 +1683,15 @@ void bigint_incr(BigInt *x) { |
| 1683 | bigint_init_unsigned(x, 1); | 1683 | bigint_init_unsigned(x, 1); |
| 1684 | return; | 1684 | return; |
| 1685 | } | 1685 | } |
| 1686 | 1686 | ||
| 1687 | if (x->digit_count == 1 && x->data.digit != UINT64_MAX) { | 1687 | if (x->digit_count == 1) { |
| 1688 | x->data.digit += 1; | 1688 | if (x->is_negative && x->data.digit != 0) { |
| 1689 | return; | 1689 | x->data.digit -= 1; |
| 1690 | return; | ||
| 1691 | } else if (!x->is_negative && x->data.digit != UINT64_MAX) { | ||
| 1692 | x->data.digit += 1; | ||
| 1693 | return; | ||
| 1694 | } | ||
| 1690 | } | 1695 | } |
| 1691 | 1696 | ||
| 1692 | BigInt copy; | 1697 | BigInt copy; |
test/behavior.zig+1| ... | @@ -13,6 +13,7 @@ comptime { | ... | @@ -13,6 +13,7 @@ comptime { |
| 13 | _ = @import("cases/bugs/656.zig"); | 13 | _ = @import("cases/bugs/656.zig"); |
| 14 | _ = @import("cases/bugs/828.zig"); | 14 | _ = @import("cases/bugs/828.zig"); |
| 15 | _ = @import("cases/bugs/920.zig"); | 15 | _ = @import("cases/bugs/920.zig"); |
| 16 | _ = @import("cases/bugs/1111.zig"); | ||
| 16 | _ = @import("cases/byval_arg_var.zig"); | 17 | _ = @import("cases/byval_arg_var.zig"); |
| 17 | _ = @import("cases/cast.zig"); | 18 | _ = @import("cases/cast.zig"); |
| 18 | _ = @import("cases/const_slice_child.zig"); | 19 | _ = @import("cases/const_slice_child.zig"); |
test/cases/bugs/1111.zig created+12| ... | @@ -0,0 +1,12 @@ | ||
| 1 | const Foo = extern enum { | ||
| 2 | Bar = -1, | ||
| 3 | }; | ||
| 4 | |||
| 5 | test "issue 1111 fixed" { | ||
| 6 | const v = Foo.Bar; | ||
| 7 | |||
| 8 | switch(v) { | ||
| 9 | Foo.Bar => return, | ||
| 10 | else => return, | ||
| 11 | } | ||
| 12 | } | ||