Bug 539 – can't instantiate nested template of same name
Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2006-11-17T03:36:00Z
Last change time
2015-06-09T05:15:21Z
Keywords
rejects-valid
Assigned to
nobody
Creator
lovesyao
Comments
Comment #0 by lovesyao — 2006-11-17T03:36:31Z
template test(T){
T test(T i)(){
return i;
}
}
int test2(int i)(){
return i;
}
template test3(T){
alias int dummy;
T test3(T i)(){
return i;
}
}
void main(){
assert(test2!(10)()==10);//ok
assert(test3!(int).test3!(10)()==10);//ok
assert(test!(int).test!(10)()==10);//compile error
assert(test!(int)!(10)()==10);//syntax error
}
Comment #1 by lovesyao — 2006-11-18T23:19:37Z
I think that more short syntax is needed for nested templates.
template Test(T)(T t){}
class Test(T)(T t){}
void Test(T)(T t)(){}
So I want that fix like test!(int)!(10)().
Comment #2 by smjg — 2007-09-09T20:33:27Z
By my analysis:
- the line commented "compile error" should not compile - because test!(int) evaluates not to the template instance itself, but to the template function therein.
- the line commented "syntax error" should compile and pass the assert.
And BTW, please report compiler messages in full.
Comment #3 by andrei — 2010-11-26T11:54:27Z
This is by design. There is no way to avoid the eponymous rewrite.