[Issue 17065] [REG2.072] Unique does not work with private members
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sat Jan 7 14:04:11 PST 2017
https://issues.dlang.org/show_bug.cgi?id=17065
--- Comment #2 from dransic at gmail.com ---
(In reply to greenify from comment #1)
> > If this behaviour is intended, the doc should state it.
>
> This should definitely have gotten a proper changelog entry (and deprecation
> warning).
> However, I am not really convinced that it should be noted in the
> documentation that access to private member variables isn't supported as
> this is the way visibility is supposed to work in D. Did anything lead you
> to this assumption or was it just by chance that accessing `private`
> variables worked and you didn't realize until the hole was fixed?
Private members are supposed to be accessible in the module where the type is
declared (module-level encapsulation). A type constructor like `Unique` should
return a type with the same access behavior. RefCounted works as I expect (but
maybe I have wrong expectations...):
---
import std.typecons : RefCounted;
struct Foo
{
private int i;
}
void main()
{
RefCounted!Foo foo = Foo(1);
foo.i = 2; // OK
}
---
--
More information about the Digitalmars-d-bugs
mailing list