6901 – wrong error "override cannot be applied to variable" in CTFE forward reference

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6901 - wrong error "override cannot be applied to variable" in CTFE forward reference
Summary: wrong error "override cannot be applied to variable" in CTFE forward reference
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Windows
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
Reported: 2011年11月07日 01:24 UTC by Don
Modified: 2015年06月09日 05:11 UTC (History)
1 user (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Don 2011年11月07日 01:24:26 UTC
Applies to both D1 and D2, at least as far back as 2.040. It's a forward reference error, triggered in this case by CTFE.
------------
class Base6900
{
 void foo() {}
}
class Derived6900: Base6900
{
 override void foo() { }
}
int test6900()
{
 Derived6900 d = new Derived6900; // for github HEAD
 // Derived6900 d = null; // for older versions
 d.foo();
 return 1;
}
static assert(test6900());
------------
test.d(8): Error: variable test.Derived6900.foo.this override cannot be applied
to variable
test.d(15): called from here: d.foo()
test.d(19): called from here: test6900()
test.d(19): Error: static assert (test6900()) is not evaluatable at compile tim
e


AltStyle によって変換されたページ (->オリジナル) /