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

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2011-11-07T01:24:00Z
Last change time
2015-06-09T05:11:38Z
Assigned to
nobody
Creator
clugdbug

Comments

Comment #0 by clugdbug — 2011-11-07T01:24:26Z
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
Comment #1 by bugzilla — 2011-11-07T23:09:24Z