gcc/testsuite/gdc.test/fail_compilation/test20610.d
raw| 1 | /* TEST_OUTPUT: |
| 2 | --- |
| 3 | fail_compilation/test20610.d(20): Error: cannot modify `const` expression `field` |
| 4 | --- |
| 5 | */ |
| 6 | |
| 7 | // https://issues.dlang.org/show_bug.cgi?id=20610 |
| 8 | |
| 9 | struct S |
| 10 | { |
| 11 | int what; |
| 12 | } |
| 13 | |
| 14 | void main() |
| 15 | { |
| 16 | S record; |
| 17 | |
| 18 | foreach (const ref field; record.tupleof) |
| 19 | { |
| 20 | field = 10; |
| 21 | } |
| 22 | } |