Skip to content

Commit

Permalink
Merge pull request #8351 from RazvanN7/Issue_15068
Browse files Browse the repository at this point in the history
Fix Issue 15068 - wrong error message on attempting to use type as template
  • Loading branch information
WalterBright committed Jun 12, 2018
2 parents ecc8d82 + 8fe1016 commit 153db26
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/dmd/dtemplate.d
Expand Up @@ -6597,7 +6597,7 @@ extern (C++) class TemplateInstance : ScopeDsymbol
Dsymbol s2 = s.getType().toDsymbol(sc);
if (!s2)
{
error("`%s` is not a template declaration, it is a %s", id.toChars(), s.kind());
.error(loc, "`%s` is not a valid template instance, because `%s` is not a template declaration but a type (`%s == %s`)", toChars(), id.toChars(), id.toChars(), s.getType.kind());
return false;
}
s = s2;
Expand Down
18 changes: 18 additions & 0 deletions test/fail_compilation/fail15068.d
@@ -0,0 +1,18 @@
/*
TEST_OUTPUT:
---
fail_compilation/fail15068.d(17): Error: `T!int` is not a valid template instance, because `T` is not a template declaration but a type (`T == int`)
fail_compilation/fail15068.d(13): Error: template instance `fail15068.Stuff!int` error instantiating
---
*/

// https://issues.dlang.org/show_bug.cgi?id=15068

void main()
{
Stuff!int s;
}
struct Stuff(T)
{
T!int var;
}

0 comments on commit 153db26

Please sign in to comment.