www.digitalmars.com         C & C++   DMDScript  

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

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: bearophile_hugs eml.cc


--- Comment #0 from bearophile_hugs 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: -------
Jul 20 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10687


hsteoh quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hsteoh quickfur.ath.cx


--- Comment #1 from hsteoh quickfur.ath.cx 2013-08-30 10:26:47 PDT ---
Verified that 2.063.2 compiles this code correctly (Linux/64bit).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 30 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10687



--- Comment #2 from hsteoh quickfur.ath.cx 2013-08-30 10:37:35 PDT ---
git bisect shows that the offending commit was:
43a6c87194cae799650249b10a4f7c910081d280

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 30 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10687



--- Comment #3 from hsteoh quickfur.ath.cx 2013-08-30 10:40:05 PDT ---
Probably a CTFE limitation/bug?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 30 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10687



--- Comment #4 from hsteoh quickfur.ath.cx 2013-08-30 14:27:23 PDT ---
The offending commit was introduced by
https://github.com/D-Programming-Language/dmd/pull/2136

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 30 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10687


Henning Pohl <henning still-hidden.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
                 CC|                            |henning still-hidden.de


--- Comment #5 from Henning Pohl <henning still-hidden.de> 2013-09-02 12:16:08
PDT ---
https://github.com/D-Programming-Language/dmd/pull/2517

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 02 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10687



--- Comment #6 from github-bugzilla puremagic.com 2013-09-03 16:21:13 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/f66f1efa8dcf76e013de31d50238ca8195850470
fix issue 10687 - Refused cast from uint[] to array of uint-based enums
at compile-time

https://github.com/D-Programming-Language/dmd/commit/6f9a34f3200f5907200f640cf8055c9dec6e795c
Merge pull request #2517 from hpohl/10687

[REG2.064a] fix issue 10687 - Refused cast from uint[] to array of uint-based
enums at compile-time

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 03 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10687


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 03 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10687


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |


--- Comment #7 from bearophile_hugs eml.cc 2013-09-03 17:26:12 PDT ---
(In reply to comment #6)
 Commits pushed to master at https://github.com/D-Programming-Language/dmd
Sorry, I think the issue is not yet fixed, some of my code like this used to work: immutable uint[5][] M = [[0, 1, 2, 3, 4]]; enum Foo : uint { A, B, C, D, E } void main() { auto foos1 = cast(immutable(Foo[5][]))M; // OK static foos2 = cast(immutable(Foo[5][]))M; // Error } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 03 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10687



--- Comment #8 from Kenji Hara <k.hara.pg gmail.com> 2013-10-01 21:38:20 PDT ---
(In reply to comment #7)
 (In reply to comment #6)
 Commits pushed to master at https://github.com/D-Programming-Language/dmd
Sorry, I think the issue is not yet fixed, some of my code like this used to work: immutable uint[5][] M = [[0, 1, 2, 3, 4]]; enum Foo : uint { A, B, C, D, E } void main() { auto foos1 = cast(immutable(Foo[5][]))M; // OK static foos2 = cast(immutable(Foo[5][]))M; // Error }
https://github.com/D-Programming-Language/dmd/pull/2612 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 01 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10687



--- Comment #9 from github-bugzilla puremagic.com 2013-10-02 17:06:58 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/4fba50787271a39fa560ce973a1eb0423d455cb5
fix Issue 10687 - Refused cast from uint[] to array of uint-based enums at
compile-time

https://github.com/D-Programming-Language/dmd/commit/cd8323733777ca8725c20892683cafb128b69283
Merge pull request #2612 from 9rnsr/fix10687

[REG2.064a] Issue 10687 - Refused cast from uint[] to array of uint-based enums
at compile-time

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 02 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10687


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 02 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10687



--- Comment #10 from bearophile_hugs eml.cc 2013-10-08 04:48:40 PDT ---
Now the code works again, thank you.

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