Skip to content

Commit

Permalink
Fix Issue 12598 - Emit better diagnostics when type is found where an…
Browse files Browse the repository at this point in the history
… lvalue was expected.
  • Loading branch information
AndrejMitrovic committed Apr 19, 2014
1 parent 05e3f24 commit 776cc73
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/expression.c
Expand Up @@ -2102,7 +2102,12 @@ Expression *Expression::toLvalue(Scope *sc, Expression *e)
e = this;
else if (!loc.filename)
loc = e->loc;
error("%s is not an lvalue", e->toChars());

if (e->op == TOKtype)
error("%s '%s' is a type, not an lvalue", e->type->kind(), e->type->toChars());
else
error("%s is not an lvalue", e->toChars());

return new ErrorExp();
}

Expand Down
21 changes: 21 additions & 0 deletions test/fail_compilation/diag12598.d
@@ -0,0 +1,21 @@
/*
TEST_OUTPUT:
---
fail_compilation/diag12598.d(13): Error: struct 'lines' is a type, not an lvalue
---
*/

class C
{
void f()
{
import imports.diag12598a;
lines ~= "";
}

string[] lines;
}

void main()
{
}
3 changes: 3 additions & 0 deletions test/fail_compilation/imports/diag12598a.d
@@ -0,0 +1,3 @@
module imports.diag12598a;

struct lines { }

0 comments on commit 776cc73

Please sign in to comment.