http://d.puremagic.com/issues/show_bug.cgi?id=8766


bearophile_h...@eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_h...@eml.cc


--- Comment #2 from bearophile_h...@eml.cc 2012-10-06 03:20:29 PDT ---
(In reply to comment #1)
> Reduced http://dpaste.dzfl.pl/348de450

Note that enums in D don't need a final semicolon. And it's better to paste or
attach the test cases in Bugzilla itself, instead of linking an external paste
site.

-----------------------

A little reduced:


enum Foo { X }
class Bar {
    static if (spam(Foo.X)) {}
    static Foo a = spam(Foo.X) ? 1 : Foo.X;
    static bool spam(Foo flag) {
        return flag != 0;
    }
}
void main() {}

DMD 2.061alpha gives:

temp.d(6): Error: variable flag cannot be read at compile time
temp.d(4):        called from here: spam(cast(Foo)0)

Replacing class with struct the error goes away.

-----------------------

Also this makes the error go away, showing it's related to a forward reference
error:

enum Foo { X }
class Bar {
    static bool spam(Foo flag) {
        return flag != 0;
    }
    static if (spam(Foo.X)) {}
    static Foo a = spam(Foo.X) ? 1 : Foo.X;
}
void main() {}

-----------------------

While this:

enum Foo { X }
class Bar {
    static if (spam(Foo.X)) {}
    static Foo a = spam(Foo.X) ? 1 : Foo.X;
    static bool spam(Foo flag) {
        return true;
    }
}
void main() {}


Gives:

temp.d(4): Error: cannot implicitly convert expression (1) of type int to Foo

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

Reply via email to