| 1 |
/* |
| 2 |
TEST_OUTPUT: |
| 3 |
--- |
| 4 |
fail_compilation/fail11503a.d(24): Error: cannot implicitly convert expression `makes()` of type `immutable(S)*` to `S*` |
| 5 |
--- |
| 6 |
*/ |
| 7 |
struct S |
| 8 |
{ |
| 9 |
immutable(S)* s; |
| 10 |
this(int) immutable pure |
| 11 |
{ |
| 12 |
s = &this; |
| 13 |
} |
| 14 |
int data; |
| 15 |
} |
| 16 |
|
| 17 |
immutable(S)* makes() pure |
| 18 |
{ |
| 19 |
return new immutable S(0); |
| 20 |
} |
| 21 |
|
| 22 |
void main() |
| 23 |
{ |
| 24 |
S* s = makes(); // s is mutable and contains an immutable reference to itself |
| 25 |
//s.s.data = 7; // this is immutable |
| 26 |
s.data = 3; // but this is not!!! |
| 27 |
} |