mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 05:00:16 +03:00
27 lines
497 B
D
27 lines
497 B
D
/*
|
|
TEST_OUTPUT:
|
|
---
|
|
fail_compilation/fail11503a.d(24): Error: cannot implicitly convert expression `makes()` of type `immutable(S)*` to `S*`
|
|
---
|
|
*/
|
|
struct S
|
|
{
|
|
immutable(S)* s;
|
|
this(int) immutable pure
|
|
{
|
|
s = &this;
|
|
}
|
|
int data;
|
|
}
|
|
|
|
immutable(S)* makes() pure
|
|
{
|
|
return new immutable S(0);
|
|
}
|
|
|
|
void main()
|
|
{
|
|
S* s = makes(); // s is mutable and contains an immutable reference to itself
|
|
//s.s.data = 7; // this is immutable
|
|
s.data = 3; // but this is not!!!
|
|
}
|