-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Warn when a user defined error message references undefined names #4008
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
Comments
Agreed that would be better, and @smarter already agreed in #4007 (comment). I tried triaging and labeling but I'm new here, might have to revisit. |
I have pretty much figured out how to implement this. Something that still puzzles me though: The argument to the annotation is not interpolated (with the So what I am asking myself is: Is there a string interpolation subsystem somewhere in the compiler that I can use to extract terms or would I have to implement that myself since the interpolation actually uses the compiler state context and not the program context? Once that question is cleared, i'd gladly take care of the issue! |
Others know better, but AFAIK: There is an interpolation subsystem in Dotty for Dotty's use, but the arguments of
However, that code is run when the message is actually used, so the error must be added elsewhere. |
Yes this seems like the use-site error reporting. For the declaration of the user-defined error string, I am looking through the literal in the RefChecks phase. But I don't want to reimplement this special kind of interpolation. Is there a spec for how such user defined messages can be structured? Is it equal to what the |
The documentation of the annotation has some details: https://www.scala-lang.org/api/2.13.3/scala/annotation/implicitNotFound.html |
Ah! Thank you kindly, then I should be all set. |
Just for the reference, I want to also add the class K[A] {
def m[B](implicit c: C[List[A], B]) = 0
def n[B](implicit @implicitNotFound("Specific message for C of list of ${A} and ${B}") c: C[List[A], B]) = 1
} For the sake of completeness, I feel like this issue should also cover this case (more generally, for all |
Both, annotated function arguments and annotated classes / traits, are now checked for invalid type variable references and warn at declaration site.
Both, annotated function arguments and annotated classes / traits, are now checked for invalid type variable references and warn at declaration site.
Both, annotated function arguments and annotated classes / traits, are now checked for invalid type variable references and warn at declaration site.
Both, annotated function arguments and annotated classes / traits, are now checked for invalid type variable references and warn at declaration site.
Both, annotated function arguments and annotated classes / traits, are now checked for invalid type variable references and warn at declaration site.
Both, annotated function arguments and annotated classes / traits, are now checked for invalid type variable references and warn at declaration site.
Currently dotty doesn't warn when you reference an unknown type parameter, but silently accepts it. It might be friendlier towards the user to warn that he probably made a typo.
The text was updated successfully, but these errors were encountered: