mirror of
https://github.com/ziglang/zig.git
synced 2026-01-01 02:53:23 +00:00
Merge pull request #1145 from isaachier/bigint-neg-one-incr-fix
Fix bigint -1 increment operation
This commit is contained in:
commit
47dd1049c8
@ -1683,10 +1683,15 @@ void bigint_incr(BigInt *x) {
|
||||
bigint_init_unsigned(x, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (x->digit_count == 1 && x->data.digit != UINT64_MAX) {
|
||||
x->data.digit += 1;
|
||||
return;
|
||||
|
||||
if (x->digit_count == 1) {
|
||||
if (x->is_negative && x->data.digit != 0) {
|
||||
x->data.digit -= 1;
|
||||
return;
|
||||
} else if (!x->is_negative && x->data.digit != UINT64_MAX) {
|
||||
x->data.digit += 1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
BigInt copy;
|
||||
|
||||
@ -13,6 +13,7 @@ comptime {
|
||||
_ = @import("cases/bugs/656.zig");
|
||||
_ = @import("cases/bugs/828.zig");
|
||||
_ = @import("cases/bugs/920.zig");
|
||||
_ = @import("cases/bugs/1111.zig");
|
||||
_ = @import("cases/byval_arg_var.zig");
|
||||
_ = @import("cases/cast.zig");
|
||||
_ = @import("cases/const_slice_child.zig");
|
||||
|
||||
12
test/cases/bugs/1111.zig
Normal file
12
test/cases/bugs/1111.zig
Normal file
@ -0,0 +1,12 @@
|
||||
const Foo = extern enum {
|
||||
Bar = -1,
|
||||
};
|
||||
|
||||
test "issue 1111 fixed" {
|
||||
const v = Foo.Bar;
|
||||
|
||||
switch(v) {
|
||||
Foo.Bar => return,
|
||||
else => return,
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user