[Issue 16190] New: to!string on enum should be fully qualified for consistency
    via Digitalmars-d-bugs 
    digitalmars-d-bugs at puremagic.com
       
    Tue Jun 21 11:13:16 PDT 2016
    
    
  
https://issues.dlang.org/show_bug.cgi?id=16190
          Issue ID: 16190
           Summary: to!string on enum should be fully qualified for
                    consistency
           Product: D
           Version: D2
          Hardware: x86
                OS: Mac OS X
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: timothee.cour2 at gmail.com
enum A{
  a1,
  a2,
}
struct B{
  A b1;
  string b2;
  int c3;
}
import std.conv:to;
void main(){
  auto b=B(A.a1, "foo", 13);
  enum b_string=`B(a1, "foo", 13)`;
  assert(b.to!string == b_string);
  mixin(`auto b1=B(A.a1, "foo", 13);`);//works
  //mixin(`auto b2=`~b_string~`;`);//Error: undefined identifier 'a1'
}
Pretty much every type in D works when reconstructing as I did above:
mixin(`auto b2=`~b.to!string~`;`);
except when there's an enum type somewhere inside
What's a workaround?
--
    
    
More information about the Digitalmars-d-bugs
mailing list