gcc/testsuite/gdc.test/fail_compilation/fail351.d
raw| 1 | /* |
| 2 | TEST_OUTPUT: |
| 3 | --- |
| 4 | fail_compilation/fail351.d(14): Error: expression `this.num[index]` of type `immutable(uint)` is not implicitly convertible to return type `ref uint` |
| 5 | --- |
| 6 | */ |
| 7 | |
| 8 | // https://issues.dlang.org/show_bug.cgi?id=2780 |
| 9 | |
| 10 | struct Immutable { |
| 11 | immutable uint[2] num; |
| 12 | |
| 13 | ref uint opIndex(size_t index) immutable return { |
| 14 | return num[index]; |
| 15 | } |
| 16 | } |
| 17 | |
| 18 | void main() { |
| 19 | immutable Immutable foo; |
| 20 | //foo[0]++; |
| 21 | } |