Bug 6310 – Missing "template instantiation" traceback when an error happens in the template parameter of an alias.
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-07-14T01:05:00Z
Last change time
2013-09-16T01:16:54Z
Keywords
diagnostic
Assigned to
nobody
Creator
kennytm
Comments
Comment #0 by kennytm — 2011-07-14T01:05:17Z
(I believe there's a duplicate, but I can't find it.)
Test case
--------------------------------------
template RT(alias f) {
alias int RT;
}
template F(T) {
alias RT!(T.dsfsdf) X; // line 5
}
pragma(msg, F!(int)); // line 7
--------------------------------------
x.d(5): Error: no property 'dsfsdf' for type 'int'
--------------------------------------
There should be another error
x.d(7): Error: template instance x.F!(int) error instantiating
Many Phobos template e.g. ForeachType suffer from this missing traceback. The error doesn't happen in D1, apparently.
Comment #1 by kennytm — 2011-07-14T01:55:44Z
More sophisticated test case which may be due to a different cause.
--------------------------------------
template SL () {
enum SL = 1;
}
template RT(alias T) if (SL!() == 1) {
alias int RT;
}
template F(T) {
alias RT!({ return T.init; }) F; // line 8
}
pragma(msg, F!(void)); // line 10
--------------------------------------
x.d(8): Error: void does not have an initializer
x.d(8): Error: void does not have a default initializer
--------------------------------------
Comment #2 by kennytm — 2011-07-14T13:36:08Z
4 more test cases: replace the contents of RT!(...) in the two comments by '[T.init, T.init]' and 'void'.
Comment #3 by kennytm — 2011-07-20T03:22:10Z
One more test case.
---------------------------
void f()() {}
@safe int g(alias key)() {
typeof(key(0)) k; // line 3.
f();
return 0;
}
void main() {
g!((int x) {
auto y = &x + 1;
return 0;
})();
}
---------------------------
x.d(3): Error: safe function 'g' cannot call system delegate '__dgliteral1'
---------------------------