Compiler error reporting 'No matching overload' error has too wide range

dotnet/fsharp#14284 FundOurselves

Watch this session

Problem

  • The error range is too wide, it includes the whole T.Instance.Method("") expression.
  • The error message is not very helpful, it doesn’t tell us which overload is being called.
  • This behaviour is especially bad on bigger expressions, lambda arguments, and so on, as the error hides every other error and warning inside the expression.
type T() =
    static member Instance = T()

    member _.Method(_: double) = ()
    member _.Method(_: int) = ()

T.Instance.Method("")
^^^^^^^^^^^^^^^^^^^^^

Error :
No overloads match for method 'Method'.
Known type of argument: string  Available overloads:
 - member T.Method: double -> unit // Argument at index 1 doesn't match
 - member T.Method: int -> unit // Argument at index 1 doesn't match

Expected behavior

  • The error range should be limited to the Method call.
  • The error message should be more specific, something like: No matching overload for 'Method' with argument type 'string'

Champion