digitalmars.D.bugs - [Issue 19681] New: std.range.padRight.popFront does not correctly
- d-bugmail puremagic.com (35/35) Feb 16 2019 https://issues.dlang.org/show_bug.cgi?id=19681
https://issues.dlang.org/show_bug.cgi?id=19681 Issue ID: 19681 Summary: std.range.padRight.popFront does not correctly adjust length Product: D Version: D2 Hardware: x86 OS: Mac OS X Status: NEW Severity: normal Priority: P1 Component: phobos Assignee: nobody puremagic.com Reporter: jrdemail2000-dlang yahoo.com padRight.popFront doesn't correctly decrement popFront.length. This will occur if padRight extended the source range. Test case: ---- test.d ---- import std.range; import std.stdio; void main(string[] args) { auto r = [1, 2, 3, 4].padRight(0, 6); writeln(r.length); r.popFront; writeln(r.length); } ---- Run ------ $ rdmd test.d 6 6 The second value should have been 5. The underlying cause is that padRight.length() returns the max of the original padded length and the length of the source range. However, padRight.popFront adjusts only the source range, leaving the original padded length unchanged. --
Feb 16 2019