digitalmars.D.bugs - [Issue 24152] New: range .until evaluates .front twice
- d-bugmail puremagic.com (30/30) Sep 19 2023 https://issues.dlang.org/show_bug.cgi?id=24152
https://issues.dlang.org/show_bug.cgi?id=24152 Issue ID: 24152 Summary: range .until evaluates .front twice Product: D Version: D2 Hardware: x86_64 OS: All Status: NEW Severity: minor Priority: P1 Component: phobos Assignee: nobody puremagic.com Reporter: d.bugs webfreak.org ``` import std.algorithm : map, until; import std.range : iota; import std.array : array; int access; int logAccess(int x) { access++; return x; } void main() { iota(10).map!logAccess.until(10).array; assert(access == 20); } ``` if you remove the `.until(10)`, you get `access == 10` --
Sep 19 2023