September 20, 2023 [Issue 24152] New: range .until evaluates .front twice | ||||
---|---|---|---|---|
| ||||
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` -- |
Copyright © 1999-2021 by the D Language Foundation