Bug 24774 – Input range + filter + chain => First element vanishes

Status
NEW
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2024-09-20T12:56:08Z
Last change time
2024-12-01T16:42:58Z
Assigned to
No Owner
Creator
anon
Moved to GitHub: phobos#9877 →

Comments

Comment #0 by qigezx+dc40d6nao940k — 2024-09-20T12:56:08Z
Chaining another range after a filtered input range omits the first element. Minimal example: import std.stdio; import std.algorithm; import std.range; void main(){ int i = 0; int gen(){ return i++; } auto r1 = generate!gen.until!(x=> x>10); auto r2 = only(100); // Will print [7.8,9,10,100] // 6 is missing r1.filter!"a>5".chain(r2).writeln; // By adding "array" before chain, it will behave properly // [6,7,8,9,10,100] // r1.array.filter!"a>5".chain(r2).writeln; // r1.filter!"a>5".array.chain(r2).writeln; } >dmd --version DMD64 D Compiler v2.109.1 Copyright (C) 1999-2024 by The D Language Foundation, All Rights Reserved written by Walter Bright os: linux x64
Comment #1 by robert.schadek — 2024-12-01T16:42:58Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/9877 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB