authorgravatar for jjhellst@gmail.comJanne Hellsten <jjhellst@gmail.com> 2026-09-26 13:55:39+03:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-09-27 01:38:23+02:00
log7126b2afd828171cb19945e00d5a6f15ea6cef4f
tree84f5b635c35089e1df8ed51506da11b8171e37b2
parent3cb5bbb36d09baf4f08464c1d047607a1f09a967

std.bit_set: bugfix Integer.setAll

Also changes the setAll test case to trigger the mask bug. The test fails without the mask fix.

1 files changed, 2 insertions(+), 1 deletions(-)

lib/std/bit_set.zig+2-1
...@@ -170,7 +170,7 @@ pub fn Integer(comptime size: u16) type {...@@ -170,7 +170,7 @@ pub fn Integer(comptime size: u16) type {
170170
171 /// Set all bits to 1.171 /// Set all bits to 1.
172 pub fn setAll(self: *Self) void {172 pub fn setAll(self: *Self) void {
173 self.mask = ~self.mask;173 self.mask = ~@as(MaskInt, 0);
174 }174 }
175175
176 /// Performs a union of two bit sets, and stores the176 /// Performs a union of two bit sets, and stores the
...@@ -1671,6 +1671,7 @@ fn testBitSet(a: anytype, b: anytype, len: usize) !void {...@@ -1671,6 +1671,7 @@ fn testBitSet(a: anytype, b: anytype, len: usize) !void {
1671 a.unsetAll();1671 a.unsetAll();
1672 try testing.expectEqual(0, a.count());1672 try testing.expectEqual(0, a.count());
16731673
1674 fillEven(a, len);
1674 a.setAll();1675 a.setAll();
1675 try testing.expectEqual(len, a.count());1676 try testing.expectEqual(len, a.count());
1676}1677}