digitalmars.D.bugs - [Issue 23397] New: private method callable from other module
- d-bugmail puremagic.com (54/54) Oct 08 2022 https://issues.dlang.org/show_bug.cgi?id=23397
https://issues.dlang.org/show_bug.cgi?id=23397 Issue ID: 23397 Summary: private method callable from other module Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: kdevel vogtner.de Source: https://forum.dlang.org/thread/dyhidpvomethytlzmkqi forum.dlang.org // file b.d import std.stdio; struct S { private void foo (ubyte c) { writeln (__PRETTY_FUNCTION__); } void foo () { } } // file a.d unittest { import b; auto s = S (); s.foo ('x'); } $ dmd -g -unittest -main a.d b.d $ ./a void b.S.foo(ubyte c) 1 modules passed unittests As Jack Pope pointed out in the forum reversing the order of definition of the methods of S gives in the expected behavior: // file b.d (reversed order) import std.stdio; struct S { void foo () { } private void foo (ubyte c) { writeln (__PRETTY_FUNCTION__); } } $ dmd -g -unittest -main b.d -run a.d a.d(5): Error: struct `b.S` function `foo` is not accessible make: *** [run] Error 1 This seems to be a regression. 2.086.1 works as expected, 2.090.1 unexpectedly compiles the code. The versions inbetween I did not check. --
Oct 08 2022