Re: private method callable from other module

2022-10-08 Thread kdevel via Digitalmars-d-learn
Issue 23397 - private method callable from other module

Re: private method callable from other module

2022-10-08 Thread kdevel via Digitalmars-d-learn
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

Re: private method callable from other module

2022-10-08 Thread Jack Pope via Digitalmars-d-learn
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.

Re: private method callable from other module

2022-10-08 Thread kdevel via Digitalmars-d-learn
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

Re: private method callable from other module

2022-10-08 Thread kdevel via Digitalmars-d-learn
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

private method callable from other module

2022-10-08 Thread kdevel via Digitalmars-d-learn
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