Skip to content

VS tooltip display too verbose when calling overloaded method with wrong parameter types #6578

Closed

Description

@smoothdeveloper

This is an error message improvement suggestion after seeing a picture posted in fsharp.org's slack (user Alanay).

Overload can be little tricky at times, when the overload count is too too high, it would be good to have the VS tooltip show a prettier summary.

Repro steps

Here is a simple case with System.Convert.ToString :

let a = System.Convert.ToString('w',4);;

Actual behavior

image

Expected behavior

Looking for proposals, here is a first one which would read better:

No overloads match for method 'ToString'.

Argument types given:
  - char
  - int
  
Available overloads:
  - Convert.ToString(value: obj, provider: IFormatProvider)
  - Convert.ToString(value: bool, provider: IFormatProvider)
  - Convert.ToString(value: bool, provider: IFormatProvider)
  - Convert.ToString(value: char, provider: IFormatProvider)
  - Convert.ToString(value: sbyte, provider: IFormatProvider)
  - Convert.ToString(value: byte, provider: IFormatProvider)
  ... exhaustive list we partially see

Workarounds

  • reduce overload count
  • taller screens

Related information

Activity

  1. added this to the 16.1 milestone on Apr 19, 2019
  2. modified the milestones: 16.1, 16.2 on Apr 23, 2019
  3. smoothdeveloper commented on Apr 25, 2019

    @smoothdeveloper
    ContributorAuthor

    I'll look at this message (sample from #2503 (comment)):

    open System
    open System.Threading.Tasks
    let makeTask () = new Task<_>(fun () -> 1)
    let task = makeTask()
    let rt1 = Task.Run(fun () -> task)

    Actual:

    A unique overload for method 'Run' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: Task.Run<'TResult>(function: Func<'TResult>) : Task<'TResult>, Task.Run<'TResult>(function: Func<Task<'TResult>>) : Task<'TResult>

    It doesn't look great in VS:

    image

    Looking for:

    A unique overload for method 'Run' could not be determined based on type information prior to this program point. 
    
    A type annotation may be needed. 
    
    Candidates: 
    - Task.Run<'TResult>(function: Func<'TResult>) : Task<'TResult>
    - Task.Run<'TResult>(function: Func<Task<'TResult>>) : Task<'TResult>
    

    Please let me know if that makes sense.

    I've made some progress in my branch (#6596) for the initial case:

    image

    There is work ahead for additional coverage of those messages as it is only lightly covered in fsharpqa tests. (edit: coverage seems appropriate)

    More input from users with verbose overload resolution messages in advanced and simple cases would be greatly appreciated.

  4. modified the milestones: 16.2, Backlog on Apr 30, 2019
  5. smoothdeveloper commented on Nov 29, 2020

    @smoothdeveloper
    ContributorAuthor

    closing this one which got merged in #6596.

  6. modified the milestones: Backlog, 16.9 on Jan 6, 2021
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

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions