D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 5387 - Unclear error message "override cannot be applied to variable"
Summary: Unclear error message "override cannot be applied to variable"
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Linux
: P4 minor
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-28 13:41 UTC by Ali Cehreli
Modified: 2012-01-20 14:16 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Ali Cehreli 2010-12-28 13:41:38 UTC
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 Walter Bright 2012-01-20 14:16:08 UTC
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.