diff --git a/src/mtype.d b/src/mtype.d index a990c902afe0..0dac3373d9a4 100644 --- a/src/mtype.d +++ b/src/mtype.d @@ -7979,23 +7979,6 @@ public: e = e.semantic(sc); return e; } - if (v) - { - if (v.toParent() != sym) - sym.error(e.loc, "'%s' is not a member", v.toChars()); - version (none) - { - // *(&e + offset) - checkAccess(e.loc, sc, e, d); - Expression b = new AddrExp(e.loc, e); - b.type = e.type.pointerTo(); - b = new AddExp(e.loc, b, new IntegerExp(e.loc, v.offset, Type.tint32)); - b.type = v.type.pointerTo(); - b = new PtrExp(e.loc, b); - b.type = v.type.addMod(e.type.mod); - return b; - } - } auto de = new DotVarExp(e.loc, e, d); return de.semantic(sc); } diff --git a/test/fail_compilation/diag15209.d b/test/fail_compilation/diag15209.d new file mode 100644 index 000000000000..341e02653b39 --- /dev/null +++ b/test/fail_compilation/diag15209.d @@ -0,0 +1,22 @@ +/* +TEST_OUTPUT: +--- +fail_compilation/diag15209.d(18): Error: need 'this' for 'x' of type 'int' +fail_compilation/diag15209.d(21): Error: need 'this' for 'x' of type 'int' +--- +*/ + +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 +}