Skip to content

Improve Error Reporting: Operator that has not been defined #2828

@Jason-Crump

Description

@Jason-Crump

What

An idea for the #1103 list. If you attempt to use an operator that you haven't defined (possibly because you've forgotten an "open" like in this StackOverflow example or in some code I just wrote myself) you can receive an error message like:

Expecting a type supporting the operator '>=>' but given a function type. You may be missing an argument to a function.

Why

Importing the operator could be a quick fix depending on the circumstances, but the error message does not point in that direction.
Currently the error suggests only looking closely at the types involved and checking for missing arguments. It is possible to follow both of those suggestions and still be unaware you've missed importing the operator.

How

The existing message isn't incorrect, so perhaps a new suggestion could be appended to it:

Expecting a type supporting the operator '>=>' but given a function type. You may be missing an argument to a function, or the operator you are trying to use may not be defined in the current scope.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-Diagnosticsmistakes and possible improvements to diagnosticsFeature ImprovementTheme-Simple-F#A cross-community initiative called "Simple F#", keeping people in the sweet spot of the language.

    Type

    No type

    Projects

    Status

    In Progress

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions