Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/dmd/typesem.d
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,13 @@ private extern (C++) final class TypeSemanticVisitor : Visitor
{
if (s)
{
s.error(loc, "is used as a type");
auto td = s.isTemplateDeclaration;
if (td && td.onemember && td.onemember.isAggregateDeclaration)
mtype.error(loc, "template %s `%s` is used as a type without instantiation"
~ "; to instantiate it use `%s!(arguments)`",
s.kind, s.toPrettyChars, s.ident.toChars);
else
mtype.error(loc, "%s `%s` is used as a type", s.kind, s.toPrettyChars);
//assert(0);
}
else
Expand Down
2 changes: 1 addition & 1 deletion test/fail_compilation/diag6539.d
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
TEST_OUTPUT:
---
fail_compilation/diag6539.d(21): Error: overloadset diag6539.Rectangle is used as a type
fail_compilation/diag6539.d(21): Error: overloadset `diag6539.Rectangle` is used as a type
---
*/

Expand Down
31 changes: 31 additions & 0 deletions test/fail_compilation/notype.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
struct S(int var = 3) {
int a;
}
S s;

alias A() = int;
A a;

enum e() = 5;
e val;

interface I()
{
}
I i;

template t()
{
}
t tv;

/*
TEST_OUTPUT:
---
fail_compilation/notype.d(4): Error: template struct `notype.S(int var = 3)` is used as a type without instantiation; to instantiate it use `S!(arguments)`
fail_compilation/notype.d(7): Error: template `notype.A()` is used as a type
fail_compilation/notype.d(10): Error: template `notype.e()` is used as a type
fail_compilation/notype.d(15): Error: template interface `notype.I()` is used as a type without instantiation; to instantiate it use `I!(arguments)`
fail_compilation/notype.d(20): Error: template `notype.t()` is used as a type
---
*/