-
-
Notifications
You must be signed in to change notification settings - Fork 610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DSSv3] Fix Issue 21685: add clearer message for private constructor #12919
Conversation
|
Thanks for your pull request and interest in making D better, @dandrei279! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla references
Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + dmd#12919" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The simpler fix would be to simply include the .kind() result in the error message:
ad.error(loc, "`%s %s` is not accessible", smember, smember.isConstructor() ? smember.kind() : "member", ...);This also does not require the phobos imported, which, as pointed out is forbidden in dmd.
Also, every new addition needs to be covered by tests.
|
ping @dandrei279 |
Hi. Sorry for delay. I 'm working on it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good
src/dmd/access.d
Outdated
| @@ -60,7 +60,7 @@ bool checkAccess(AggregateDeclaration ad, Loc loc, Scope* sc, Dsymbol smember) | |||
| return false; | |||
| } | |||
|
|
|||
| ad.error(loc, "member `%s` is not accessible%s", smember.toChars(), (sc.flags & SCOPE.onlysafeaccess) ? " from `@safe` code".ptr : "".ptr); | |||
| ad.error(loc, "`%s %s` is not accessible%s", smember.kind(), smember.toChars, (sc.flags & SCOPE.onlysafeaccess) ? " from `@safe` code".ptr : "".ptr); | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the first format specifier should be outside the opening backtick. i.e. the format string to the error call should be
"%s `%s` is not accessible%s"
not
"`%s %s` is not accessible%s"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @RazvanN7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I agree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mind the nit and we're good to go.
…lang#12919) * Fix Issue 21685: add clearer message for private constructor * Rewrite the error message for private members; Update and create tests. * Fix backtick position in error message
The error message for accessing the private constructor is clear now.
Old message:
Error: class<class_name>memberthisis not accessibleCurrent message:
Error: class<class_name>Constructoris not accessible