Bug 5387 – Unclear error message "override cannot be applied to variable"
Status
RESOLVED
Resolution
WORKSFORME
Severity
minor
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Linux
Creation time
2010-12-28T13:41:00Z
Last change time
2012-01-20T14:16:08Z
Assigned to
nobody
Creator
acehreli
Comments
Comment #0 by acehreli — 2010-12-28T13:41:38Z
It is not easy to see that the dmd error message in the subject line probably means something like "member function templates cannot be virtual." (Or after the language of the spec page, "Templates cannot be used to add virtual functions to classes.")
class Derived
{
override void foo(T)()
{}
}
void main()
{
auto d = new Derived();
d.foo!int();
}
Abreviated lines from dmd 2.051 output:
... Error: variable deneme.Derived.foo!(int).foo.this override cannot be applied to variable
... Error: template instance deneme.Derived.foo!(int) error instantiating
Comment #1 by bugzilla — 2012-01-20T14:16:08Z
The error message is now:
foo.d(3): Error: function foo.Derived.foo!(int).foo cannot override a non-virtual function
which I think is adequate.