Skip to content

Commit

Permalink
Merge pull request #7441 from ntrel/qual-incompatible
Browse files Browse the repository at this point in the history
Issue 9631 - Error message not using fully qualified name (part 2)
merged-on-behalf-of: Mike Franklin <JinShil@users.noreply.github.com>
  • Loading branch information
dlang-bot committed Dec 16, 2017
2 parents db75da8 + 51b0dce commit 6504493
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 5 deletions.
12 changes: 10 additions & 2 deletions src/dmd/expression.d
Expand Up @@ -4827,11 +4827,19 @@ extern (C++) abstract class BinExp : Expression
TOK thisOp = (op == TOKquestion) ? TOKcolon : op;
if (e1.op == TOKtype || e2.op == TOKtype)
{
error("incompatible types for ((%s) %s (%s)): cannot use '%s' with types", e1.toChars(), Token.toChars(thisOp), e2.toChars(), Token.toChars(op));
error("incompatible types for ((%s) %s (%s)): cannot use '%s' with types",
e1.toChars(), Token.toChars(thisOp), e2.toChars(), Token.toChars(op));
}
else if (e1.type.equals(e2.type))
{
error("incompatible types for ((%s) %s (%s)): both operands are of type '%s'",
e1.toChars(), Token.toChars(thisOp), e2.toChars(), e1.type.toChars());
}
else
{
error("incompatible types for ((%s) %s (%s)): '%s' and '%s'", e1.toChars(), Token.toChars(thisOp), e2.toChars(), e1.type.toChars(), e2.type.toChars());
auto ts = toAutoQualChars(e1.type, e2.type);
error("incompatible types for ((%s) %s (%s)): '%s' and '%s'",
e1.toChars(), Token.toChars(thisOp), e2.toChars(), ts[0], ts[1]);
}
return new ErrorExp();
}
Expand Down
21 changes: 21 additions & 0 deletions test/fail_compilation/bug9631.d
Expand Up @@ -19,3 +19,24 @@ void main()
{
T2!().F x = T1!().F();
}

/*
TEST_OUTPUT:
---
fail_compilation/bug9631.d(41): Error: incompatible types for ((x) == (y)): 'bug9631.S' and 'bug9631.tem!().S'
---
*/

struct S { char c; }

template tem()
{
struct S { int i; }
}

void equal()
{
S x;
auto y = tem!().S();
bool b = x == y;
}
2 changes: 1 addition & 1 deletion test/fail_compilation/fail11445.d
@@ -1,7 +1,7 @@
/*
TEST_OUTPUT:
---
fail_compilation/fail11445.d(11): Error: incompatible types for ((a) + (b)): 'double[string]' and 'double[string]'
fail_compilation/fail11445.d(11): Error: incompatible types for ((a) + (b)): both operands are of type 'double[string]'
---
*/

Expand Down
3 changes: 2 additions & 1 deletion test/fail_compilation/fail3.d
@@ -1,7 +1,7 @@
/*
TEST_OUTPUT:
---
fail_compilation/fail3.d(40): Error: incompatible types for ((a) + (b)): 'vec2' and 'vec2'
fail_compilation/fail3.d(41): Error: incompatible types for ((a) + (b)): both operands are of type 'vec2'
---
*/

Expand All @@ -14,6 +14,7 @@ template vector(T)
T x, y;
}

// not struct member
vec2 opAdd(vec2 a, vec2 b)
{
vec2 r;
Expand Down
2 changes: 1 addition & 1 deletion test/fail_compilation/fail79.d
@@ -1,7 +1,7 @@
/*
TEST_OUTPUT:
---
fail_compilation/fail79.d(13): Error: incompatible types for ((& a) + (& b)): 'int*' and 'int*'
fail_compilation/fail79.d(13): Error: incompatible types for ((& a) + (& b)): both operands are of type 'int*'
---
*/

Expand Down

0 comments on commit 6504493

Please sign in to comment.