Bug 24384 – roundRobin crashes with empty first argument

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2024-02-10T06:51:27Z
Last change time
2024-02-14T16:31:35Z
Keywords
pull
Assigned to
No Owner
Creator
Paul Backus

Comments

Comment #0 by snarwin+bugzilla — 2024-02-10T06:51:27Z
As of Phobos 2.107.0, the following program crashes with an AssertError at runtime: --- void main() { import std.range: roundRobin; auto r = roundRobin("", "a"); if (!r.empty) auto e = r.front; } --- The error message is: --- core.exception.AssertError@/usr/include/dmd/phobos/std/range/package.d(2351): Attempting to fetch the front of an empty roundRobin ---------------- ??:? _d_assert_msg [0x558a54569f5c] /usr/include/dmd/phobos/std/range/package.d:2353 pure @property @safe dchar std.range.roundRobin!(immutable(char)[], immutable(char)[]).roundRobin(immutable(char)[], immutable(char)[]).Result.front() [0x558a545601a1] ./bug.d:7 _Dmain [0x558a5455f75d] ---
Comment #1 by dlang-bot — 2024-02-10T07:33:10Z
@pbackus created dlang/phobos pull request #8911 "Skip leading empty ranges in roundRobin" fixing this issue: - Skip leading empty ranges in roundRobin Previously, roundRobin would always attempt to fetch its first element from the first range passed to it, even if that range was empty. Fixes bugzilla issue 24384. https://github.com/dlang/phobos/pull/8911
Comment #2 by dlang-bot — 2024-02-14T16:31:35Z
dlang/phobos pull request #8911 "Skip leading empty ranges in roundRobin" was merged into master: - 720ac51ea123da95ea8fab65cbdab988484d83e6 by Paul Backus: Skip leading empty ranges in roundRobin Previously, roundRobin would always attempt to fetch its first element from the first range passed to it, even if that range was empty. Fixes bugzilla issue 24384. https://github.com/dlang/phobos/pull/8911