Improve Error Reporting: Make FS0039 easier to read at a glance. · Issue #13012...
source link: https://github.com/dotnet/fsharp/issues/13012
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
The following error message is super common and could be made less intimidating:
type Person = { Name : string } let isaac = { Name = "Isaac" } let fullName = isaac.Fooo + " Abraham" // The type 'Person' does not define the field, constructor or member 'Fooo'.
The error message makes perfect sense, but for the beginner I feel it could be made more welcoming. In addition, the fact that it shows the type rather than the symbol name is a little confusing - especially if that type has been inferred.
I would prefer to see an error something like as follows:
isaac.Fooo
does not exist (isaac
is typePerson
).- Unknown member
isaac.Fooo
(isaac
is typePerson
).
Notice that we use the same symbol name and path as the actual code sample, which hopefully draws people's attention to the source of the issue. In the current error message, you have to read all the way to the end to see what the issue is.
I suppose we could keep the current "type-oriented" message but still improve it e.g.:
Fooo
does not exist on the typePerson
.Fooo
does not exist on this symbol, which has typePerson
.
I'm not sure when else this error message is shown, so it's possible I've missed some other obvious cases etc.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK