digitalmars.D.bugs - [Issue 19980] New: File.byLine skips first line in some cases when
- d-bugmail puremagic.com (39/39) Jun 17 2019 https://issues.dlang.org/show_bug.cgi?id=19980
https://issues.dlang.org/show_bug.cgi?id=19980 Issue ID: 19980 Summary: File.byLine skips first line in some cases when used inside map!() Product: D Version: D2 Hardware: x86_64 OS: Windows Status: NEW Severity: normal Priority: P1 Component: phobos Assignee: nobody puremagic.com Reporter: nairolf online.de I have tried to reduce this file as much as I could: --- import std.stdio, std.algorithm, std.range; void main( ) { // Preparation... auto fw = File("deleteme.txt", "w"); fw.write("Line 1\nLine 2\nLine 3\n"); fw.close(); File[] files = [File("deleteme.txt")]; // Next line contains the bug: files.map!(f => f.byLine).tee!writeln.each; } --- Prints: ["Line 2\r", "Line 3\r"] Should print: ["Line 1\r", "Line 2\r", "Line 3\r"] It works correctly if I remove the tee!() and put the writeln in the each!(): files.map!(f => f.byLine).each!writeln; It also works correctly if there is an ".array" after the map: files.map!(f => f.byLine).array.tee!writeln.each; The ".tee!writeln" is just there to generate some readable output. This was originally found by using .joiner, where it also skips the first line: auto a = files.map!(f => f.byLine).joiner; Tested on DMD v2.087.0-beta.1 and LDC 1.15.0 (based on DMD v2.085.1). --
Jun 17 2019