Issue 23397 - private method callable from other module
On Saturday, 8 October 2022 at 10:05:33 UTC, kdevel wrote:
```
$ dmd -g -unittest -main -run a.d b.d
a.o: In function `_D1a16__unittest_L2_C1FZv':
(...)./a.d:5: undefined reference to `_D1b1S3fooMFhZv'
collect2: error: ld returned 1 exit status
Error: linker exited with status 1
```
`b.d` is th
Altering the definition sequence in b.d to have the private
version second has the desired result. Otherwise, when following
private foo, it looks like public foo gets adopted as a public
constructor. The same for classes.
On Saturday, 8 October 2022 at 09:59:17 UTC, kdevel wrote:
On Saturday, 8 October 2022 at 09:46:59 UTC, kdevel wrote:
```
$ dmd -g -unittest -main a.d b.d
$ ./a
void b.S.foo(ubyte c)
1 modules passed unittests
```
2.086.1
a.d(5): Error: struct `b.S` member foo is not accessible
2.09
On Saturday, 8 October 2022 at 09:46:59 UTC, kdevel wrote:
```
$ dmd -g -unittest -main a.d b.d
$ ./a
void b.S.foo(ubyte c)
1 modules passed unittests
```
2.086.1
a.d(5): Error: struct `b.S` member foo is not accessible
2.090.1
compiles
Is this a known bug?
```
// file b.d
import std.stdio;
struct S {
private void foo (ubyte c)
{
writeln (__PRETTY_FUNCTION__);
}
void foo ()
{
}
}
```
```a.d
// file a.d
unittest {
import b;
auto s = S ();
s.foo ('x');
}
```
```
$ dmd -g -unittest -main a.d b.d