digitalmars.D.bugs - [Issue 23216] New: Better Error Message For foreach_reverse Without
- d-bugmail puremagic.com (36/36) Jun 27 2022 https://issues.dlang.org/show_bug.cgi?id=23216
https://issues.dlang.org/show_bug.cgi?id=23216 Issue ID: 23216 Summary: Better Error Message For foreach_reverse Without Bidirectional Range Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: jack jackstouffer.com When a range is given to foreach_reverse, but it doesn't have back and popBack, DMD gives a confusing error message. ``` import std.algorithm; import std.stdio; void main() { string a = "This||is||a||test!"; foreach_reverse (word; a.splitter("||")) writeln(word); } ``` Gives: ``` Error: invalid `foreach` aggregate `splitter(a, "||")`, define `opApply()`, range primitives, or use `.tupleof` ``` Expected Behavior: DMD should detect that the given value is an input range print something like "Error: Input range splitter(a, "||") passed as foreach aggregate. foreach_reverse requires a bidirectional range" --
Jun 27 2022