This should not be allowed. Otherwise, you can call a const method on a base class and the derived class can change the object.
I believe the fix that should be implemented should follow the same rules as today's override rules. i.e., same function name/args, but derived method has different const specicification results in a different signature, and therefore a different overload.
Here is code that demonstrates the issue:
import std.stdio;
class A
{
int x;
const void f()
{
writefln("A");
}
}
class B : A
{
override void f()
{
x = 2;
writefln("B");
}
}
void main(){
A y = new B;
y.f;
}
[steves@localhost svn]$ dmd testme.d
gcc testme.o -o
testme -m32 -Xlinker -L/home/steves/dmd2/dmd/bin/../lib -lphobos2 -lpthread
-lm
[steves@localhost svn]$ ./testme
B
[steves@localhost svn]$
Comment #1 by schveiguy — 2008-10-21T10:57:43Z
Bumping the severity up. This really is a terrible bug, especially since we are getting closer and closer to pure functions. This bug has existed way too long.