Bug 21685 – bad error message on private constructor: member this is not accessible

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2021-03-07T15:10:20Z
Last change time
2021-08-02T08:11:32Z
Keywords
pull, trivial
Assigned to
Andrei David
Creator
Tobias Pankrath

Comments

Comment #0 by tobias — 2021-03-07T15:10:20Z
--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.
Comment #1 by tobias — 2021-03-07T15:11:03Z
This confused other people on discord, too. So I am not the only one.
Comment #2 by nightmarex1337 — 2021-03-07T15:29:52Z
Can confirm.
Comment #3 by razvan.nitu1305 — 2021-03-08T11:09:55Z
Yes, the type of the member should be explicitly stated to avoid any type of confusion.
Comment #4 by dlang-bot — 2021-07-25T14:51:20Z
@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
Comment #5 by dlang-bot — 2021-08-02T08:11:32Z
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