Skip to content

Commit

Permalink
fix Issue 11487 - dmd segfaults on writefln in nested template
Browse files Browse the repository at this point in the history
  • Loading branch information
9rnsr committed Nov 22, 2013
1 parent 40c8ba9 commit 7d3752c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/template.c
Expand Up @@ -5282,9 +5282,11 @@ void TemplateInstance::semantic(Scope *sc)
void TemplateInstance::expandMembers(Scope *sc2)
{
for (size_t i = 0; i < members->dim; i++)
{ Dsymbol *s = (*members)[i];
{
Dsymbol *s = (*members)[i];
s->setScope(sc2);
}

for (size_t i = 0; i < members->dim; i++)
{
Dsymbol *s = (*members)[i];
Expand Down Expand Up @@ -7548,6 +7550,12 @@ void TemplateMixin::semantic(Scope *sc)
fatal();
}

for (size_t i = 0; i < members->dim; i++)
{
Dsymbol *s = (*members)[i];
s->setScope(sc2);
}

for (size_t i = 0; i < members->dim; i++)
{
Dsymbol *s = (*members)[i];
Expand Down
27 changes: 27 additions & 0 deletions test/runnable/mixin1.d
Expand Up @@ -1185,6 +1185,33 @@ void test9417()
}
}

/*******************************************/
// 11487

template X11487()
{
struct R()
{
C11487 c;

~this()
{
static assert(is(typeof(c.front) == void));
}
}
template Mix(alias R)
{
R!() range;
@property front() inout {}
}
}

class C11487
{
alias X11487!() M;
mixin M.Mix!(M.R);
}

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

int main()
Expand Down

0 comments on commit 7d3752c

Please sign in to comment.