Bug 1525 – Can't instantiate template with bogus error messages
Status
RESOLVED
Resolution
FIXED
Severity
trivial
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2007-09-22T20:18:00Z
Last change time
2014-02-15T13:12:43Z
Keywords
diagnostic
Assigned to
nobody
Creator
davidl
Comments
Comment #0 by davidl — 2007-09-22T20:18:08Z
template k(U:V[C])
{
void func(U a, C v){writefln("hello");};
}
int[char]v;
char m;
k!(int[char]).func(v);
gives me:
abc.d(7): variable abc.v conflicts with variable abc.v at abc.d(5)
abc.d(1): Error: identifier 'C' is not defined
abc.d(1): Error: index is not a type or an expression
abc.d(1): Error: identifier 'V' is not defined
abc.d(1): Error: V is used as a type
modify the last line to k!(int[char]).func(v,m) gives me:
abc.d(7): found ',' when expecting ')'
abc.d(7): semicolon expected, not 'm'
abc.d(7): no identifier for declarator m
abc.d(7): semicolon expected, not ')'
abc.d(7): Declaration expected, not ')'
Comment #1 by davidl — 2007-09-22T20:34:24Z
this bug is for nicer error messages maybe hint user that missing template list of (U:V[C],C) for such a specialization.
Comment #2 by smjg — 2007-10-29T08:00:13Z
INVALID I think but....
template k(U:V[C], V, C)
{
void func(U a, C v){writefln("hello");};
}
works, and can be instantiated as k!(int[int]).
Comment #3 by yebblies — 2011-06-12T22:00:34Z
Dmd now complains that V and C are undefined (dmd 1.068 & 2.053) which correctly identifies the problem.
testx.d(1): Error: undefined identifier C, did you mean template k(U : V[C])?
testx.d(1): Error: undefined identifier V, did you mean template k(U : V[_error_
])?