0

Improve Error Reporting: Make FS0039 easier to read at a glance. · Issue #13012...

 2 years ago
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.

Copy link

Contributor

isaacabraham commented 8 days ago

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 type Person).
  • Unknown member isaac.Fooo (isaac is type Person).

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 type Person.
  • Fooo does not exist on this symbol, which has type Person.

I'm not sure when else this error message is shown, so it's possible I've missed some other obvious cases etc.

edgarfgp, DaveJohnson8080, and ma3yta reacted with thumbs up emoji

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK