[Issue 24342] New: T[][].until(T[]) breaks if sentinel is longer than 1.
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Jan 17 13:12:08 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=24342
Issue ID: 24342
Summary: T[][].until(T[]) breaks if sentinel is longer than 1.
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: major
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: default_357-line at yahoo.de
import std;
void main()
{
int[] marker = [2, 3];
int[][] first = [[1], [2, 3], [4]];
int[][] second = first.until(marker, No.openRight).array;
assert(second == [[1], [2, 3]]);
}
Instead, `second` is [[1], [2, 3], [4]].
This happens because `until` does not differentiate "range is T[] and sentinel
is T[]" from "range is _T[][]_ and sentinel is T[]". This leads it to advance
two rather than one elements if the sentinel is two long.
--
More information about the Digitalmars-d-bugs
mailing list