cmd/compile: further improve precision of "has no field or method" by prescriptively mentioning what kind of property it is either "field" or "method" #38965
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
A few weeks ago, I listened to the GoTimeFM interview https://twitter.com/GoTimeFM/status/1255875570275094529 with @eliasnaur, and thanks to interviewers and organizers @mdlayher @joncalhoun @jboursiquot @johanbrandhorst @rakyll
Motivations
In that episode, one of the things that they mentioned that they liked and mentioned about Go being a modern language is that the Go compiler is prescriptive in its error messages; for example lwhen you try to use a field with mismatched case, we'll error with the suggestion of the mismatch e.g.
Given this program https://play.golang.org/p/CRyflGpyRyg or inlined below:
which produces
Suggestion
The error messages are nice but I think that we can be even more prescriptive and say
I just submitted another CL 201657 to fix #31053, in which we improve the error for unexported fields by telling the user for example
while in that CL, at some point I implemented some logic for defining the distinction between field and method but it was deemed to be beyond the scope of issue #31053 per comment/typecheck.go#925
so this issue is a placeholder for that functionality. I can have a CL ready in about 10 minutes, and we also have the motivation which is the reception and feedback that Go users provide us.
The end result is that instead of
we'll now have
Kindly paging my fellow compiler+syntax crew @mdempsky and @griesemer who have been helping with reviews for these updates for us to further improve compiler error messages.
The text was updated successfully, but these errors were encountered: