I am attempting to read the content of a file byte by byte and I got a runtime error for reaching unreachable behavior.
output of zig build run:
/usr/lib/zig/std/posix.zig:1174:23: 0x114f2af in preadv (std.zig)
.INVAL => unreachable,
^
/usr/lib/zig/std/fs/File.zig:1372:31: 0x114afe3 in readVecPositional (std.zig)
const n = posix.preadv(r.file.handle, dest, r.pos) catch |err| switch (err) {
^
/usr/lib/zig/std/fs/File.zig:1345:73: 0x1148629 in readVec (std.zig)
.positional, .positional_reading => return readVecPositional(r, data),
^
/usr/lib/zig/std/Io/Reader.zig:1063:56: 0x111fdb9 in fillUnbuffered (std.zig)
while (r.end < r.seek + n) _ = try r.vtable.readVec(r, &bufs);
^
/usr/lib/zig/std/Io/Reader.zig:1049:26: 0x1107bef in fill (std.zig)
return fillUnbuffered(r, n);
^
/usr/lib/zig/std/Io/Reader.zig:1089:13: 0x1142ff2 in peekByte (std.zig)
try fill(r, 1);
^
/usr/lib/zig/std/Io/Reader.zig:1097:32: 0x114194f in takeByte (std.zig)
const result = try peekByte(r);
^
/home/###/Dev/###/src/parser.zig:35:56: 0x113f5be in tokenizeFile (parser.zig)
const char: u8 = inputReader.interface.takeByte() catch |err| {
^
/home/###/Dev/###/src/main.zig:16:36: 0x113d4ce in main (main.zig)
const Tokens = try tokenizeFile(gpa, "testfile.flx", definitions.items);
^
/usr/lib/zig/std/start.zig:627:37: 0x113e099 in posixCallMainAndExit (std.zig)
const result = root.main() catch |err| {
^
/usr/lib/zig/std/start.zig:232:5: 0x113d351 in _start (std.zig)
asm volatile (switch (native_arch) {
^
???:?:?: 0x0 in ??? (???)
run
+- run exe flx failure
error: the following command terminated unexpectedly:
./.zig-cache/o/ba005b7d1399ec9d623ba23e1c544d72/flx
Build Summary: 1/3 steps succeeded; 1 failed
run transitive failure
+- run exe flx failure
error: the following build command failed with exit code 1:
.zig-cache/o/ad2bf62510af3be0bcd6f92ce2f6eee2/build /usr/bin/zig /usr/lib/zig /home/###/Dev/flx .zig-cache /home/###/.cache/zig --seed 0xae3c618a -Z9b74f59d7f97fec0 run
Is this a problem with my program or the standard library?