Bug 8002 – Excess initial errors when passing template args to non-templated struct
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-04-29T14:14:00Z
Last change time
2012-04-30T12:01:43Z
Keywords
diagnostic, pull
Assigned to
nobody
Creator
bus_dbugzilla
Comments
Comment #0 by bus_dbugzilla — 2012-04-29T14:14:11Z
---------------
import std.stdio;
struct Foo
{
int a;
}
int bar()
{
writeln();
return 1;
}
void main()
{
Foo x = Foo!(bar());
}
---------------
A template argument is (accidentally) being passed to Foo. The compiler should, and does, print a "not a template declaration" error. But before doing so, it evaluates the completely erroneous template arg, resulting in a big pile of totally non-applicable error text ("cannot be interpreted at compile time") which obscures the one real problem.
>dmd test.d
C:\Documents and Settings\Nick Sabalausky\Application Data\dvm\compilers\dmd-2.059\bin\..\src\phobos\std\stdio.d(1548): Error: fputc cannot be interpreted at compile time, because it has no available source code
C:\Documents and Settings\Nick Sabalausky\Application Data\dvm\compilers\dmd-2.059\bin\..\src\phobos\std\stdio.d(1548): called from here: enforce(fputc(10,(*stdout.p).handle) == 10,delegate pure nothrow @safe const(char)[]()
{
return null;
}
)
test.d(10): called from here: writeln()
test.d(16): called from here: bar()
test.d(16): Error: template instance Foo!(bar()) Foo is not a template declaration, it is a struct