| 1 |
/* |
| 2 |
TEST_OUTPUT: |
| 3 |
--- |
| 4 |
fail_compilation/foreach2.d(15): Error: argument type mismatch, `int` to `ref immutable(int)` |
| 5 |
fail_compilation/foreach2.d(16): Error: argument type mismatch, `int` to `ref immutable(int)` |
| 6 |
fail_compilation/foreach2.d(19): Error: argument type mismatch, `int` to `ref double` |
| 7 |
fail_compilation/foreach2.d(20): Error: argument type mismatch, `int` to `ref const(double)` |
| 8 |
fail_compilation/foreach2.d(21): Error: argument type mismatch, `int` to `ref immutable(double)` |
| 9 |
--- |
| 10 |
*/ |
| 11 |
void test4090 () |
| 12 |
{ |
| 13 |
// From https://issues.dlang.org/show_bug.cgi?id=4090 |
| 14 |
int[] arr = [1,2,3]; |
| 15 |
foreach (immutable ref x; arr) {} |
| 16 |
foreach (immutable ref int x; arr) {} |
| 17 |
|
| 18 |
// convertible type + qualifier + ref |
| 19 |
foreach ( ref double x; arr) {} |
| 20 |
foreach ( const ref double x; arr) {} |
| 21 |
foreach (immutable ref double x; arr) {} |
| 22 |
} |