www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14784] New: Variant and Proxy don't get along


          Issue ID: 14784
           Summary: Variant and Proxy don't get along
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: ryan rcorre.net

Created attachment 1530
  --> https://issues.dlang.org/attachment.cgi?id=1530&action=edit
Test case for using Variant and Proxy

If a struct forwards access to a member via Proxy, assignment to a Variant


import std.typecons, std.variant;

struct Foo { int f; }

struct Bar {
  private Foo foo;
  mixin Proxy!foo;

  int b;

unittest {
  Bar b;
  Variant v = b;

/usr/include/dlang/dmd/std/typecons.d(4432): Error: e2ir: cannot cast this.foo
of type Foo to type string

Using `alias this` instead of Proxy alleviates the issue (but I must make foo
non-private for alias this, hence my desire to use Proxy).

Jul 07 2015