Skip to content

Commit

Permalink
Merge pull request #5118 from 9rnsr/fix_dotidexp
Browse files Browse the repository at this point in the history
Issue 15116 & 15117 - fix bugs in DotIdExp.semanticY
  • Loading branch information
yebblies committed Mar 28, 2016
2 parents 148fc4c + 3c70f27 commit d2ee18c
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 5 deletions.
12 changes: 8 additions & 4 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 Expand Up @@ -8449,8 +8452,9 @@ public:
{
if (eleft)
{
error("cannot have e.tuple");
return new ErrorExp();
e = new DotVarExp(loc, eleft, tup);
e = e.semantic(sc);
return e;
}
e = new TupleExp(loc, tup);
e = e.semantic(sc);
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
37 changes: 37 additions & 0 deletions test/runnable/xtest46.d
Expand Up @@ -7659,6 +7659,43 @@ void test15045()
test!(S3, false)();
}

/***************************************************/
// 15116

alias TypeTuple15116(T...) = T;

template Mix15116()
{
TypeTuple15116!(int, int) tup;
}

struct S15116
{
mixin Mix15116 mix;
}

void test15116()
{
S15116 s;
auto x1 = s.tup; // OK
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 d2ee18c

Please sign in to comment.