Skip to content

Improve error reporting: Accidental use of , instead of ; as record field separator #1122

@isaacabraham

Description

@isaacabraham

What

The following error message is generated from this code snippet:

type Person = { Name : string; Age : int; City : string }
let x = { Name = "Isaac", Age = 21, City = "London" } // , instead of ;

error FS0001: This expression was expected to have type string but here has type 'a * 'b * 'c

Why

Newcomers to F# syntax (or otherwise!) may accidentally use , instead of ; as field separators. The error message is not helpful in this case - the inclusion of generics in the message further complicates matters and does not aid the developer with the real problem.

How

Replace the error message with something like: -

F# uses ; to separate fields values when creating a record, not , e.g. let x = { Name = "Isaac"; Age = 21 ... }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions