Skip to content

[Diagnostics] Better error message for conversion of fun to System.Func #3568

Description

@0x53A

The general rule of thumb when interoping with C# is that methods in C# are tupled in F#... except when you try to create a new System.Func.

Example:

open System

// Error:
// [FS0001] Type mismatch. Expecting a
//    'string -> int -> string * int'    
// but given a
//    ''a * 'b -> 'a * 'b'    
//The type 'string' does not match the type ''a * 'b'
let func : Func<string, int, string*int> =
   let f (s,i) = (s,i)
   Func<string, int, string*int>(f)

// Ok
let func : Func<string, int, string*int> =
   let f s i = (s,i)
   Func<string, int, string*int>(f)

In the spirit of the "elmish" error message improvements a few months ago, it would be awesome if the compiler could detect this case and give explicit instructions how to resolve this.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status
    In Progress

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions