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

--- Comment #0 from Adam D. Ruppe <> 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!(string).to!(Test) error

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!(Test).to!(string) error

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:
------- You are receiving this mail because: -------

Reply via email to