Make std.BitStack.pop return an optional #22282
Labels
breaking
Implementing this issue could cause existing code to no longer compile or have different behavior.
proposal
This issue suggests modifications. If it also has the "accepted" label then it is planned.
standard library
This issue involves writing Zig code for the standard library.
Milestone
Zig Version
0.14.0-dev.2545+e2e363361
Steps to Reproduce and Observed Behavior
Call
peek
orpush
on an emptystd.BitStack
or callstd.BitStack.peekWithState
orstd.BitStack.popWithState
with abit _len.*
of0
.This will result in an integer overflow panic due to subtracting from zero.
Code to reproduce
Panic output
Expected Behavior
I think there are multiple ways to improve/fix this behaviour of these functions, they are ordered in decending order of practicality in my opinion:
self.bit_len
/bit_len.*
are greater than zero. This shouldn't affect the stdlib at all.std.json.Scanner
to have to be rewritten/fixed.isEmpty
tostd.BitStack
to make this behaviour more clear through the interface, this also shouldn't affect the stdlib.The text was updated successfully, but these errors were encountered: