| 1 |
/* |
| 2 |
TEST_OUTPUT: |
| 3 |
--- |
| 4 |
fail_compilation/test23216.d(23): Error: invalid `foreach_reverse` aggregate `r` of type `Range` |
| 5 |
fail_compilation/test23216.d(23): `foreach_reverse` works with bidirectional ranges (implementing `back` and `popBack`), aggregates implementing `opApplyReverse`, or the result of an aggregate's `.tupleof` property |
| 6 |
fail_compilation/test23216.d(23): https://dlang.org/phobos/std_range_primitives.html#isBidirectionalRange |
| 7 |
--- |
| 8 |
*/ |
| 9 |
|
| 10 |
// https://issues.dlang.org/show_bug.cgi?id=23216 |
| 11 |
// Better Error Message For foreach_reverse Without Bidirectional Range |
| 12 |
|
| 13 |
struct Range |
| 14 |
{ |
| 15 |
bool empty = true; |
| 16 |
int front = 0; |
| 17 |
void popFront() { } |
| 18 |
} |
| 19 |
|
| 20 |
void main() |
| 21 |
{ |
| 22 |
Range r; |
| 23 |
foreach_reverse (word; r) { } |
| 24 |
} |