-
Notifications
You must be signed in to change notification settings - Fork 833
Closed
Labels
Milestone
Description
What
If the LHS and RHS of an anonymous record expression does not match, the compiler gives a list of all fields on both sides, even if 99 out of 100 fields match.
let foo : {| Name : string; Age : int; DOB : DateTime; Duration : TimeSpan |} =
{| Age = 10; Foo = true; Bar = false, 10 |}gives the error
error FS0001: Two anonymous record types have mismatched sets of field names '["Age"; "DOB"; "Duration"; "Name"]' and '["Age"; "Bar"; "Foo"]'
Why
This rapidly becomes difficult to work with on anything but small anonymous records, especially if you simply have a typo in a single field e.g. FullName and Fullname or similar. Often, developers will construct an anonymous record by creating a single field and then "fill in the blanks" based on the compiler error message until all fields are populated.
How
- Omit fields that already match
- Show missing fields separately
- Show extra fields separately
e.g.
error FS0001: Two anonymous record types have mismatched field names. The following fields fields must be added: '["Age"; "DOB"; "Duration"]`. The following fields must be removed: `["Bar; "Foo"]`
For cases where the RHS is a subset or superset, the other part of the error message can be truncated as needed.
ma3yta, ChrisNikkel, abelbraaksma and auduchinok