Not sure .. is this a bug?
Frits van Bommel
fvbommel at REMwOVExCAPSs.nl
Thu Jun 28 05:01:18 PDT 2007
Downs wrote:
> import std.stdio;
>
> class foo { int e; abstract const void bar(); }
>
> class bug: foo { void bar() { writefln("I NOW CHANGEZ TEH OBJECTS"); e=5; } }
>
> void main() {
> const(bug) okay=new bug;
> // okay.bar; fails as expected
> const(foo) Bug=cast(foo)okay;
> Bug.bar; // interestingly works.
> }
>
> From my POV, the Bug.bar is modifying data it shouldn't be able to modify, but then again, I'm rather new to the whole constness thing. So, is this a bug?
I'd have expected the compiler to give an error when trying to override
"const void bar()" with "void bar()" in 'bug'...
More information about the Digitalmars-d
mailing list