| 1 |
/* |
| 2 |
TEST_OUTPUT: |
| 3 |
--- |
| 4 |
fail_compilation/b20011.d(28): Error: cannot modify expression `S1(cast(ubyte)0u).member` because it is not an lvalue |
| 5 |
fail_compilation/b20011.d(31): Error: cannot modify expression `S2(null).member` because it is not an lvalue |
| 6 |
fail_compilation/b20011.d(32): Error: cannot modify expression `S2(null).member` because it is not an lvalue |
| 7 |
fail_compilation/b20011.d(35): Error: cannot modify expression `U1(cast(ubyte)0u, ).m2` because it is not an lvalue |
| 8 |
fail_compilation/b20011.d(40): Error: function `assignableByRef` is not callable using argument types `(ubyte)` |
| 9 |
fail_compilation/b20011.d(40): cannot pass rvalue argument `S1(cast(ubyte)0u).member` of type `ubyte` to parameter `ref ubyte p` |
| 10 |
fail_compilation/b20011.d(37): `b20011.main.assignableByRef(ref ubyte p)` declared here |
| 11 |
fail_compilation/b20011.d(41): Error: function `assignableByOut` is not callable using argument types `(ubyte)` |
| 12 |
fail_compilation/b20011.d(41): cannot pass rvalue argument `S1(cast(ubyte)0u).member` of type `ubyte` to parameter `out ubyte p` |
| 13 |
fail_compilation/b20011.d(38): `b20011.main.assignableByOut(out ubyte p)` declared here |
| 14 |
fail_compilation/b20011.d(42): Error: function `assignableByConstRef` is not callable using argument types `(ubyte)` |
| 15 |
fail_compilation/b20011.d(42): cannot pass rvalue argument `S1(cast(ubyte)0u).member` of type `ubyte` to parameter `ref const(ubyte) p` |
| 16 |
fail_compilation/b20011.d(39): `b20011.main.assignableByConstRef(ref const(ubyte) p)` declared here |
| 17 |
--- |
| 18 |
*/ |
| 19 |
module b20011; |
| 20 |
|
| 21 |
struct S1 { ubyte member; } |
| 22 |
struct S2 { ubyte[] member; } |
| 23 |
union U1 { ubyte m1; int m2; } |
| 24 |
|
| 25 |
void main() |
| 26 |
{ |
| 27 |
enum S1 s1 = {}; |
| 28 |
s1.member = 42; |
| 29 |
|
| 30 |
enum S2 s2 = {}; |
| 31 |
s2.member = []; |
| 32 |
s2.member ~= []; |
| 33 |
|
| 34 |
enum U1 u1 = {m1 : 0}; |
| 35 |
u1.m2 = 42; |
| 36 |
|
| 37 |
void assignableByRef(ref ubyte p){ p = 42; } |
| 38 |
void assignableByOut(out ubyte p){ p = 42; } |
| 39 |
void assignableByConstRef(ref const ubyte p){} |
| 40 |
assignableByRef(s1.member); |
| 41 |
assignableByOut(s1.member); |
| 42 |
assignableByConstRef(s1.member); |
| 43 |
} |