Skip to content

Improve error reporting: Function accidentally partially applied #1107

@isaacabraham

Description

@isaacabraham

What

Oftentimes, you may add a curried argument to a function after the fact, or called a curried function and simply forgot the last argument. All callsites will break (correct) but the error is generally not what you would expect. Look at the following example: -

let foo a b = a + b
let c = foo 10
let d = c + 10

The error returned is error FS0001: The type 'int' does not match the type 'int -> int'

Why

New developers to F# may be unfamiliar with the concept of pervasive type inference and / or of passing functions as values and / or of partially applied functions. The error message does not make entirely clear why this error is occurring.

How

This makes sense, but again, to a new developer, it's completely confusing. A preferred error may be something like: -

The value 'c' is a partially applied function with signature 'int -> int' and is not compatible with 10. Did you forget to provide all the partial arguments when creating 'c'?

If it is not easily possible from the AST to understand that this is a partially applied function (entirely possible), it should still be possible to make a clearer message saying you are trying to do something across a function and a simple value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Feature 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