September 21, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3934



--- Comment #10 from bearophile_hugs@eml.cc 2010-09-21 13:28:24 PDT ---
Structs can't be subclassed, so protected struct fields seem a bug. This compiles with dmd 2.049:


struct Foo {
    protected int x;
}
void main() {}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 26, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3934



--- Comment #11 from bearophile_hugs@eml.cc 2010-09-26 10:40:03 PDT ---
This compiles with no errors with dmd 2.049, but I'd like a compile-time error similar to "manifest constants are always static":


void foo() {
    static enum x = 10;
}
void main() {}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 05, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3934



--- Comment #12 from bearophile_hugs@eml.cc 2010-11-05 11:17:28 PDT ---
See the closed bug 5171 for code that may be disallowed statically:


class A {
    @disable override equals_t opEquals(Object other) {
        return false;
    }
}

void main() {
    auto a = new A();
    auto b = new A();

    if(a == b)
        assert(0);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 08, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3934



--- Comment #13 from bearophile_hugs@eml.cc 2010-11-08 03:24:30 PST ---
This is C# code:

class Foo {}
public class Test : Foo {
    public static void Main() {}
}


The C# compiler gives this error:
prog.cs(2,14): error CS0060: Inconsistent accessibility: base class `Foo' is
less accessible than class `Test'


While the D 2.050 compiler gives no errors with this code:

private class Foo {}
public class Bar : Foo {}
void main() {}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 08, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3934



--- Comment #14 from bearophile_hugs@eml.cc 2010-11-08 04:19:31 PST ---
This bug is now fixed:

auto pure foo() {
    return 1;
}
pure void bar() {
    foo();
}
void main() {}


DMD 2.050 gives the error:

test.d(5): Error: pure function 'bar' cannot call impure function 'foo'

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 08, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3934



--- Comment #15 from bearophile_hugs@eml.cc 2010-11-08 04:38:03 PST ---
(In reply to comment #14)
> This bug is now fixed:

Ignore comment #14, the bug is not fixed, sorry.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 23, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3934



--- Comment #16 from bearophile_hugs@eml.cc 2011-01-23 07:18:39 PST ---
This shows something strange, dmd 2.051:

const struct Foo1 { int* p; }
struct Foo2 { int* p; }
void bar1(Foo1 f1) {}
void bar2(Foo2 f2) {}
void main() {
    const f1 = Foo1();
    bar1(f1); // no error
    const f2 = Foo2();
    bar2(f2); // error
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 23, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3934



--- Comment #17 from bearophile_hugs@eml.cc 2011-01-23 09:26:37 PST ---
(In reply to comment #16)
> This shows something strange, dmd 2.051:

According to Mafi that code is correct: http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.learn&article_id=24058

> I think it's absolutely correct. Look: Foo3 is declared as const
> struct meaning all it's members are const. We are passing a struct
> like that to bar3:
>  const Foo3 { const int* p}
> which is implicitely converted to:
>  Foo3 { const int* p } //not ref !!
> Because it's not ref you can't manipulate the original struct anyways
> and the pointer is still const. As long as you don't cast you cannot
> change what the pointer points to so this implicit conversion is
> correct IMO.
> It's like const(T[]) => const(T)[] .

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 24, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3934



--- Comment #18 from bearophile_hugs@eml.cc 2011-01-23 16:18:58 PST ---
Another variant of the code, found by Dan Olson, this compiles and runs with no errors with DMD 2.051:

struct Foo { int x; }
void bar(ref Foo f) { f.x = 1; }
void main() {
    const f = Foo();
    bar(f);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 19, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3934



--- Comment #19 from bearophile_hugs@eml.cc 2011-03-19 06:47:16 PDT ---
It seems "emum" implies "static":


enum X = 10;
void main() {
    enum int X = 20;
    static int foo() {
        return X; // No errors
    }
    assert(foo() == 20); // No errors
}


Yet this compiles:

void main() {
    enum static int x = 1;
}


While this:

void main() {
    static static int x = 1;
}

Produces the error:
test.d(2): redundant storage class 'static'

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------