Skip to content

Improve error reporting: when type mismatch error involves a tuple, say it is a tuple #11234

Description

@cartermp

Consider the following error message:

This expression was expected to have type
    'string'
but here has type
    ''a * 'b'

This can arise in code like this:

let g a b = "hello"

let f a b : string =
     g a, b

I got some feedback from a newcomer that this was confusing for several reasons:

  1. They weren't used to F# parameter applications yet and accidentally used a comma
  2. They didn't know what the * meant in the error message

The first confusion could potentially be made better by a code fixer.

The second one would need a better error message. I propose the following:

This expression was expected to have type:
    'string'
but here is a tuple of type:
    ''a * 'b'

This could still be confusing, but at least it's explicitly saying that it's a tuple type.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions