gcc/testsuite/gdc.test/fail_compilation/fail20448.d
raw| 1 | /* |
| 2 | TEST_OUTPUT: |
| 3 | --- |
| 4 | fail_compilation/fail20448.d(16): Error: returning `p.x` escapes a reference to parameter `p` |
| 5 | fail_compilation/fail20448.d(22): Error: template instance `fail20448.member!"x"` error instantiating |
| 6 | --- |
| 7 | */ |
| 8 | |
| 9 | struct S |
| 10 | { |
| 11 | int x, y; |
| 12 | } |
| 13 | |
| 14 | ref int member(string mem)(S p) |
| 15 | { |
| 16 | return p.x; |
| 17 | } |
| 18 | |
| 19 | void main() |
| 20 | { |
| 21 | S p; |
| 22 | p.member!"x" = 2; |
| 23 | } |