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

           Summary: std.traits.isSomeString no longer works with enums
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: Phobos
        AssignedTo: nob...@puremagic.com
        ReportedBy: jmdavisp...@gmx.com


--- Comment #0 from Jonathan M Davis <jmdavisp...@gmx.com> 2012-08-04 14:20:31 
PDT ---
This code passes with 2.059 but fails with 2.060:

import std.traits;

enum E : string { a = "hello" }
static assert(isSomeString!(typeof(E.a)));

void main()
{
}

It's commit

https://github.com/D-Programming-Language/phobos/commit/52462bec6ea846f30e8dac309d63ccb4101e8f0c

which broke this. Kenji Hara argues that enums should be treated as strongly
typed by std.traits, but the language itself doesn't do this.

auto func(string s) {...}

will accept E.a just fine, but no

auto func(S)(S s) if(isSomeString!S) {...}

will not. Kenji also points out that std.traits has not been consistent with
regards to how it treats enums, and

enum U : uint { a = 0 }
static assert(isUnsigned!(typeof(U.a)));

fails with both 2.059 and 2.060. I'd argue that it should pass as well.

Needing to distinguish between an enum of a particular base type and that exact
type is quite rare AFAIK (std.conv.to and std.format care but not a lot else).
As such, I really think that we'd be better off if std.traits treats enums as
their base types and let code which cares about whether a particular template
argument is an enum or not check whether it's an enum - that's what is(T ==
enum) is for.

As it stands, it's _very_ easy to break code which uses enums when templatizing
a function which wasn't previously templatized, and std.traits is completely
inconsistent with the language with regards to enums. This needs to be fixed.

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

Reply via email to