Bug 1102 – switch case couldn't contain template member
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
All
Creation time
2007-04-06T01:11:00Z
Last change time
2014-02-16T15:22:00Z
Assigned to
bugzilla
Creator
davidl
Comments
Comment #0 by davidl — 2007-04-06T01:11:32Z
In my opinion, the following should be compilable:
enum type{
a,
b,
}
class myclass
{
template XX(uint a, uint c)
{
uint XX(){ return (a*256+c);}
}
void testcase()
{
switch (cast(uint)type.a)
{
case XX!(cast(uint)type.a,cast(uint)type.b)(): /*emit me error message: case must be a string or an integral constant, not (this.XX)()*/
break;
}
}
}
void main()
{
}
Comment #1 by bugzilla — 2007-04-06T02:12:56Z
uint XX(){ return (a*256+c);}
should be:
static uint XX(){ return (a*256+c);}
as non-static member functions cannot be evaluated at compile time.