Skip to content

Commit

Permalink
fix Issue 15117 - Unreasonable circular reference error via named mixin
Browse files Browse the repository at this point in the history
  • Loading branch information
9rnsr committed Mar 28, 2016
1 parent b51fecf commit 3c70f27
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/expression.d
Expand Up @@ -8367,9 +8367,12 @@ public:
if (v)
{
//printf("DotIdExp:: Identifier '%s' is a variable, type '%s'\n", toChars(), v->type->toChars());
if (v.inuse)
if (!v.type)
{
error("circular reference to '%s'", v.toChars());
if (v.inuse)
error("circular reference to '%s'", v.toChars());
else
error("forward reference of %s %s", s.kind(), s.toChars());
return new ErrorExp();
}
if (v.needThis())
Expand Down
2 changes: 1 addition & 1 deletion test/fail_compilation/fail89.d
@@ -1,7 +1,7 @@
/*
TEST_OUTPUT:
---
fail_compilation/fail89.d(9): Error: circular reference to 'a'
fail_compilation/fail89.d(9): Error: circular initialization of a
---
*/

Expand Down
15 changes: 15 additions & 0 deletions test/runnable/xtest46.d
Expand Up @@ -7681,6 +7681,21 @@ void test15116()
auto x2 = s.mix.tup; // OK <- NG
}

/***************************************************/
// 15117

template Mix15117()
{
int y = { typeof(this)* s; return s ? s.mix.y : 0; }();
}

struct S15117
{
int x = { typeof(this)* s; return s ? s.x : 0; }(); // OK

mixin Mix15117 mix; // OK <- NG
}

/***************************************************/
// 15126

Expand Down

0 comments on commit 3c70f27

Please sign in to comment.