[Issue 10687] New: Refused cast from uint[] to array of uint-based enums at compile-time

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jul 20 16:14:49 PDT 2013


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

           Summary: Refused cast from uint[] to array of uint-based enums
                    at compile-time
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2013-07-20 16:14:49 PDT ---
I think this used to be accepted:


enum Foo : uint { A, B, C, D, E }
void main() {
    static immutable uint[5] a1 = [0, 1, 2, 3, 4]; // line 3
      auto a2 = cast(immutable(Foo[5]))a1; // OK
    static a3 = cast(immutable(Foo[5]))a1; // line 5, error
}



test.d(3): Error: cannot implicitly convert expression ([0u, 1u, 2u, 3u, 4u])
of type immutable(uint[5u]) to immutable(Foo[5u])

Also the error line number is wrong, the right line number is 5.

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


More information about the Digitalmars-d-bugs mailing list