--bad_error_main.d import bad_error; void main() { new E; } -- --bad_error.d module bad_error; class E { private this() {} } -- Gives: bad_error_main.d(5): Error: class bad_error.E member this is not accessible That confused me a lot. I first thought that there is somehow a problem with the this-pointer, not with the constructor. My proposal is to fit `constructor` somewhere in there: constructor `this` is not accessible or similar.
This confused other people on discord, too. So I am not the only one.
Can confirm.
Yes, the type of the member should be explicitly stated to avoid any type of confusion.
@dandrei279 created dlang/dmd pull request #12919 "[DSSv3] Fix Issue 21685: add clearer message for private constructor" fixing this issue: - Fix Issue 21685: add clearer message for private constructor https://github.com/dlang/dmd/pull/12919
dlang/dmd pull request #12919 "[DSSv3] Fix Issue 21685: add clearer message for private constructor" was merged into master: - 0b1f5d661a3528231aa6b856642c25976a7a8e28 by Andrei David: Fix Issue 21685: add clearer message for private constructor https://github.com/dlang/dmd/pull/12919