### Zig Version 0.15.1 ### Steps to Reproduce and Observed Behavior `zig run` following code: ```zig const std = @import("std"); pub fn main() !void { var fixed: std.Io.Reader = .fixed("abc"); var limited = fixed.limited(@enumFromInt(1), &.{}); // hangs forever _ = try limited.interface.discardRemaining(); } ``` ### Expected Behavior should exit loop after discarding all remaining data
Activity
Mus-42 commentedon Aug 21, 2025
it happens because on after first iteration it calls
discard(0)after first iteration of
discardRemainingloop:limited.remainingis set to 0Reader.Limited.discardcomputescombined_limitas 0, then callsdiscard(0)on fixedIo.Reader.discard(0)can't returnerror.EndOfStream(0 always triggers early return) so loop never exitshttps://github.com/ziglang/zig/blob/cab6d752e8f6f6d3f538075840acc108238feda3/lib/std/Io/Reader.zig#L266..L275
https://github.com/ziglang/zig/blob/cab6d752e8f6f6d3f538075840acc108238feda3/lib/std/Io/Reader/Limited.zig#L52..L58
i guess solution would be to return
error.EndOfStreaminsideReader.Limited.discardwhenremaining <= limitwhatisaphone commentedon Oct 9, 2025
I ran OP's code after #25512 (on 529aa9f) and it no longer hangs. This can be closed!
andrewrk commentedon Oct 9, 2025
Thanks for checking!