digitalmars.D - Attribute hiding, strict compiler
- bearophile (60/60) Nov 08 2010 I have just added a issue about class/struct attribute hiding:
I have just added a issue about class/struct attribute hiding:
http://d.puremagic.com/issues/show_bug.cgi?id=5187
public class Foo {
public int x = 10;
}
public class Test : Foo {
public int x = 20; // warning
public static void Main() {}
}
warning CS0108: `Test.x' hides inherited member `Foo.x'. Use the new keyword if
hiding was intended
public class Foo {
public int x = 10;
}
public class Test : Foo {
new public int x = 20; // OK
public static void Main() {}
}
--------------------
and tidy. Compared to it DMD feels quite sloppy. So I am asking Walter if this
is something temporary, that will change, or it is something meant to be. Here
I am especially thinking about my wide issue 3934:
http://d.puremagic.com/issues/show_bug.cgi?id=3934
DMD 2.050 compiles the following horror program with no errors or warnings:
auto scope shared import std.stdio;
static foo1() {}
final foo2() {}
ref foo3() {}
enum void foo4() {}
nothrow foo5() {}
pure foo6() {}
extern struct foo7;
struct Foo8 { static invariant() {} }
__gshared struct foo9 { int n; }
struct Foo10 { protected int x; }
void foo11() { static enum x = 10; }
private class Foo12 {}
public class Foo13 : Foo12 {}
static int x1 = 10;
static x2 = 10;
class Base {
private final ~this() { writeln("Base.~this"); }
}
class Derived : Base {
private final ~this() { writeln("Derived.~this"); }
}
class A {
disable override equals_t opEquals(Object other) { return false; }
}
auto void main() {
new Derived();
auto a = new A();
auto b = new A();
if (a == b)
assert(0);
}
your eye in a fraction of second.
So is DMD supposed to become (much) more strict?
Bye,
bearophile
Nov 08 2010








bearophile <bearophileHUGS lycos.com>