dmd/compiler/test/fail_compilation/diag15209.d
Dennis c4e84f226e
Improve "need this" error (#15430)
* Improve "need `this`" error for function calls

* Improve "need `this`" error for member variables

* Improve "need this" error for address of variable

* Remove dead error
2023-07-20 12:41:02 +03:00

22 lines
488 B
D

/*
TEST_OUTPUT:
---
fail_compilation/diag15209.d(18): Error: accessing non-static variable `x` requires an instance of `C1`
fail_compilation/diag15209.d(21): Error: accessing non-static variable `x` requires an instance of `S2`
---
*/
class C1 { int x; }
struct S1 { alias y = C1.x; }
struct S2 { int x; }
class C2 { alias y = S2.x; }
void main()
{
S1 s1;
s1.y = 10; // invalid field variable access
auto c2 = new C2();
c2.y = 10; // invalid field variable access
}