www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17065] New: Unique does not work with private members

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

          Issue ID: 17065
           Summary: Unique does not work with private members
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: dransic gmail.com

This code doesn't compile anymore:

---
import std.typecons : Unique;

struct Foo
{
    private int i;
}

void main()
{
    Unique!Foo foo = new Foo(1);
    foo.i = 2;  // Error: no property 'i' for type 'Unique!(Foo)'
}
---

It compiled before https://github.com/dlang/phobos/pull/4763 was merged. But
the new implementation uses Proxy, which is a template mixin that is
instantiated from std.typecons itself.

If this behaviour is intended, the doc should state it.

--
Jan 07