Skip to content

Commit

Permalink
fix Issue 13921 - ICE with template instantiation error
Browse files Browse the repository at this point in the history
  • Loading branch information
9rnsr committed Jan 2, 2015
1 parent 60bdb8c commit 70eda8d
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 deletions.
8 changes: 7 additions & 1 deletion src/mtype.c
Expand Up @@ -6729,6 +6729,11 @@ void TypeInstance::resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymb
{
//printf("s = %s\n", s->toChars());
s->semantic(sc);
if (!global.gag && tempinst->errors)
{
*pt = terror;
return;
}
}
resolveHelper(loc, sc, s, NULL, pe, pt, ps, intypeid);
if (*pt)
Expand All @@ -6754,7 +6759,8 @@ Type *TypeInstance::semantic(Loc loc, Scope *sc)
if (!t)
{
if (!e && s && s->errors)
{ // if there was an error evaluating the symbol, it might actually
{
// if there was an error evaluating the symbol, it might actually
// be a type. Avoid misleading error messages.
error(loc, "%s had previous errors", toChars());
}
Expand Down
4 changes: 2 additions & 2 deletions src/template.c
Expand Up @@ -2618,8 +2618,8 @@ FuncDeclaration *TemplateDeclaration::doHeaderInstantiation(

if (global.endGagging(olderrors))
{
assert(fd->type->ty != Tfunction);
return NULL;
if (fd->type->ty != Tfunction)
return NULL;
}
assert(fd->type->ty == Tfunction);

Expand Down
3 changes: 1 addition & 2 deletions test/fail_compilation/ice11086.d
@@ -1,8 +1,7 @@
/*
TEST_OUTPUT:
---
fail_compilation/ice11086.d(11): Error: template instance foo!A template 'foo' is not defined
fail_compilation/ice11086.d(11): Error: foo!A had previous errors
fail_compilation/ice11086.d(10): Error: template instance foo!A template 'foo' is not defined
---
*/

Expand Down
27 changes: 27 additions & 0 deletions test/fail_compilation/ice13921.d
@@ -0,0 +1,27 @@
/*
TEST_OUTPUT:
---
fail_compilation/ice13921.d(13): Error: undefined identifier undefined_identifier
fail_compilation/ice13921.d(25): Error: template instance ice13921.S!string error instantiating
---
*/

struct S(N)
{
void fun()
{
undefined_identifier;
// or anything that makes the instantiation fail
}

}

void test(T)(S!T)
{
}

void main()
{
S!string g;
test(g);
}

0 comments on commit 70eda8d

Please sign in to comment.