Skip to content

Commit

Permalink
Merge pull request #5196 from 9rnsr/fix15209
Browse files Browse the repository at this point in the history
Issue 15209 - redundant error message on invalid field access
  • Loading branch information
AndrejMitrovic committed Oct 16, 2015
2 parents 6e137f5 + 41fe4c1 commit e5f4f76
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
17 changes: 0 additions & 17 deletions src/mtype.d
Expand Up @@ -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);
}
Expand Down
22 changes: 22 additions & 0 deletions 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
}

0 comments on commit e5f4f76

Please sign in to comment.