www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13763] New: std.string.representation of immutables

https://issues.dlang.org/show_bug.cgi?id=13763

          Issue ID: 13763
           Summary: std.string.representation of immutables
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P1
         Component: Phobos
          Assignee: nobody puremagic.com
          Reporter: bearophile_hugs eml.cc

I am not sure this is a bug, but it seems an incongruence:


void main() {
    import std.string: representation;
    enum Enum : char { A = 'a' }
    const Enum[] a1;
    auto r1 = a1.representation; // OK
    immutable Enum[] a2;
    auto r2 = a2.representation; // Error
}



dmd 2.067alpha gives:

...\dmd2\src\phobos\std\string.d(1769,12): Error: cast from immutable(Enum)[]
to immutable(ubyte)[] not allowed in safe code
temp.d(7,17): Error: template instance
std.string.representation!(immutable(Enum)) error instantiating

--
Nov 22 2014