[Issue 5056] Warning against virtual method call from constructor
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Jun 5 07:26:57 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=5056
Michal Minich <michal.minich at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |michal.minich at gmail.com
--- Comment #11 from Michal Minich <michal.minich at gmail.com> 2013-06-05 07:26:54 PDT ---
dmd 2.063 - instance method is called before constructor.
module test;
import std.stdio;
class Base
{
this () {
writeln("Base.this");
foo(); // here should come warning: calling virtual method in
constructor
}
void foo () { writeln("Base.foo"); }
}
class Derived : Base
{
this () { writeln("Derived.this"); }
override void foo () { writeln("Derifed.foo"); }
}
void main () { auto d = new Derived; }
Program output:
Base.this
Derifed.foo // method Derived.foo is called before object constructor
Derived.this
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list