If I define the following module:
---
module foo;
struct Foo
{
import std : writeln;
private int _x;
private ref int x() return
{
writeln("ref int");
return _x;
}
int x() const
{
writeln("int");
return _x;
}
}
---
and in another module:
---
void main()
{
import std : writeln;
import foo : Foo;
auto f = Foo();
f.x = 3;
writeln(f);
}
---
then the program prints
---
ref int
Foo(3)
---
so I have gained access to private method x and member _x.
dlang/dmd pull request #15319 "Make 'private function is not accessible' deprecation an error." was merged into master:
- fd0ebb96e18d3fa54d53bfb71210da2ff9135463 by Mathis Beer:
Make 'private function is not accessible' deprecation an error.
Affects issue 21275, 23947.
https://github.com/dlang/dmd/pull/15319