Bug 1532 – Template instance cannot use class locals as template parameters
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
All
OS
All
Creation time
2007-09-26T03:35:00Z
Last change time
2014-02-17T22:47:18Z
Keywords
rejects-valid
Assigned to
nobody
Creator
samukha
Comments
Comment #0 by samukha — 2007-09-26T03:35:35Z
The feature was implemented for function locals way back in D 0.173 but still doesn't work for class locals
class Foo
{
template Bar(alias local)
{
}
int x;
alias Bar!(x) bar;
}
Error: template instance cannot use local 'x' as template parameter
This was actually a diagnostic error, it is fixed by 2.020. The error message now explains that the template must be global; there's actually no difference in behaviour between function locals and class locals.
Marking this as FIXED because of the error message (nobody will be confused again in the same way). The code still doesn't compile, but the code below has always worked:
template Bar(alias local)
{
}
class Foo
{
int x;
alias Bar!(x) bar;
}