[Issue 7909] New: to!(enum)(string) and to!(string)(enum) break when enum is integral

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Apr 14 07:19:11 PDT 2012


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

           Summary: to!(enum)(string) and to!(string)(enum) break when
                    enum is integral
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: destructionator at gmail.com


--- Comment #0 from Adam D. Ruppe <destructionator at gmail.com> 2012-04-14 07:19:59 PDT ---
import std.conv;

enum Test { a = -1, b = 0, c = 1 }

void main() {
    assert(to!string(Test.a) == "a"); // matches more than one
    assert(to!Test("b") == Test.b); // does not match anything
}

First line error:
Error: template std.conv.toImpl matches more than one template declaration,
src/phobos/std/conv.d(1034):toImpl(T,S) if (!isImplicitlyConvertible!(S,T) &&
is(S == enum) && isSomeString!(T)) and src/phobos/std/conv.d(1155):toImpl(T,S)
if (isIntegral!(S) && isSigned!(S) && isSomeString!(T))
e.d(6): Error: template instance std.conv.to!(string).to!(Test) error
instantiating


Second line error:
src/phobos/std/conv.d(244): Error: template std.conv.toImpl does not match any
function template declaration
src/phobos/std/conv.d(244): Error: template std.conv.toImpl cannot deduce
template function from argument types !(Test)(string)
src/phobos/std/conv.d(244): Error: template instance toImpl!(Test) errors
instantiating template
e.d(7): Error: template instance std.conv.to!(Test).to!(string) error
instantiating




This worked correctly on dmd 2.058.


Note that if you use an enum without assigned values (enum Test {a,b,c}), it
still works.

-- 
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