www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12494] New: to!string(enum) returns incorrect value

reply d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12494

           Summary: to!string(enum) returns incorrect value
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: zan77137 nifty.com


--- Comment #0 from SHOO <zan77137 nifty.com> 2014-03-30 11:03:23 PDT ---
This code doesn't work:
--------- main.d ---------
enum E
{
    a = 0,
    b = 0,
    c = 1,
}

void main()
{
    import std.stdio, std.conv, std.string;
    assert(format("%s", E.c) == "c"); // main(11): OK
    assert(to!string(E.c) == "c");    // main(12): NG
}

--------- RESULT ---------
$ dmd -run main
core.exception.AssertError main(12): Assertion failure
---------

I think it is strange that to!string returns incorrect value though format
returns correct value.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 30 2014
next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12494


monarchdodra gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |monarchdodra gmail.com


--- Comment #1 from monarchdodra gmail.com 2014-03-30 12:44:25 PDT ---
Thanks. I know what is causing this. Fixing ASAP.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 30 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12494


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich gmail.com
            Summary|to!string(enum) returns     |Regression (2.064):
                   |incorrect value             |to!string(enum) returns
                   |                            |incorrect value
           Severity|normal                      |regression


--- Comment #2 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2014-03-30
23:34:45 CEST ---
Similar but the opposite:
https://d.puremagic.com/issues/show_bug.cgi?id=10814

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 30 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12494



--- Comment #3 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2014-03-30
23:36:57 CEST ---
(In reply to comment #1)
 Thanks. I know what is causing this.

Yeah, we went a bit overboard with avoiding allocations and ended up using indexing, but forgetting we're calling NoDuplicates when generating the switch/case. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 30 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12494



--- Comment #4 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2014-03-30
23:37:40 CEST ---
(In reply to comment #1)
 Fixing ASAP.

We could use __traits(getMember) unless you find another solution. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 30 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12494



--- Comment #5 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2014-03-30
23:38:38 CEST ---
(In reply to comment #2)
 Similar but the opposite:
 https://d.puremagic.com/issues/show_bug.cgi?id=10814

Oops I didn't want to post this. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 30 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12494


Vladimir Panteleev <thecybershadow gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |thecybershadow gmail.com


--- Comment #6 from Vladimir Panteleev <thecybershadow gmail.com> 2014-03-31
00:48:15 EEST ---
(In reply to comment #1)
 Thanks. I know what is causing this. Fixing ASAP.

Introduced in https://github.com/D-Programming-Language/phobos/pull/1565 in case anyone still wants to know -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 30 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12494



--- Comment #7 from github-bugzilla puremagic.com 2014-03-31 13:10:19 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/78d84e515a7551fd7536595730abf943dc573c04
Fix Issue 12494 - to!string(enum) incorrect value

https://github.com/D-Programming-Language/phobos/commit/7a94226a22c7ca3f6e997aeb2b18621dcfea5834
Merge pull request #2059 from monarchdodra/12494

Fix  Issue 12494 - Regression (2.064): to!string(enum) returns incorrect value

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 31 2014
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12494


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

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


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