www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16190] New: to!string on enum should be fully qualified for


          Issue ID: 16190
           Summary: to!string on enum should be fully qualified for
           Product: D
           Version: D2
          Hardware: x86
                OS: Mac OS X
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: timothee.cour2 gmail.com

enum A{

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?

Jun 21 2016