Skip to content

Commit

Permalink
fix Issue 12981 - Can't refer to 'outer' from mixin template
Browse files Browse the repository at this point in the history
  • Loading branch information
9rnsr committed Jun 29, 2014
1 parent 2ffcbeb commit 394a58a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/declaration.c
Expand Up @@ -2111,7 +2111,8 @@ bool VarDeclaration::isDataseg()
return false;
Dsymbol *parent = this->toParent();
if (!parent && !(storage_class & STCstatic))
{ error("forward referenced");
{
error("forward referenced");
type = Type::terror;
return false;
}
Expand Down
2 changes: 2 additions & 0 deletions src/mtype.c
Expand Up @@ -8524,6 +8524,8 @@ Expression *TypeClass::dotExp(Scope *sc, Expression *e, Identifier *ident, int f
}
if (ident == Id::outer && sym->vthis)
{
if (sym->vthis->scope)
sym->vthis->semantic(NULL);
s = sym->vthis;
}
else
Expand Down
18 changes: 18 additions & 0 deletions test/runnable/nested.d
Expand Up @@ -2383,6 +2383,24 @@ void test12234()
assert(b.a == 1);
}

/*******************************************/
// 12981

template Mix12981(T)
{
class A
{
alias typeof(this.outer) x;
}
}

class B12981
{
mixin Mix12981!(int);

static assert(is(A.x == B12981));
}

/*******************************************/

int main()
Expand Down

0 comments on commit 394a58a

Please sign in to comment.