Showing with 38 additions and 0 deletions.
  1. +22 −0 src/parse.d
  2. +16 −0 test/fail_compilation/diag15186.d
22 changes: 22 additions & 0 deletions src/parse.d
Original file line number Diff line number Diff line change
Expand Up @@ -4438,6 +4438,16 @@ public:
Token* t = peek(&token);
if (t.value == TOKcolon)
{
Token* nt = peek(t);
if (nt.value == TOKcolon)
{
// skip ident::
nextToken();
nextToken();
nextToken();
error("use '.' for member lookup, not '::'");
break;
}
// It's a label
Identifier ident = token.ident;
nextToken();
Expand Down Expand Up @@ -6485,6 +6495,18 @@ public:
{
case TOKidentifier:
{
Token* t1 = peek(&token);
Token* t2 = peek(t1);
if (t1.value == TOKmin && t2.value == TOKgt)
{
// skip ident->
nextToken();
nextToken();
nextToken();
error("use '.' for member lookup, not '->'");
goto Lerr;
}

if (peekNext() == TOKgoesto)
goto case_delegate;
id = token.ident;
Expand Down
16 changes: 16 additions & 0 deletions test/fail_compilation/diag15186.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
TEST_OUTPUT:
---
fail_compilation/diag15186.d(14): Error: use '.' for member lookup, not '::'
fail_compilation/diag15186.d(15): Error: use '.' for member lookup, not '->'
---
*/

void main()
{
struct S { static int x; int y; }
S* s;

S::x = 1;
s->y = 2;
}