fsharp icon indicating copy to clipboard operation
fsharp copied to clipboard

Tooltip in IDE suggests wrong type of parameter or even multiple types

Open BoundedChenn31 opened this issue 1 year ago • 2 comments

Repro steps

type U1 = { Name: string }
type U2 = { Age: int; Name: string }

let test =
    seq<U1 -> string> {
        fun u -> u.Name
    }
    |> Seq.map (fun (f: U1 -> string) -> [| f |])
  1. Hover over u parameter. Tooltip says that it's type is U2 but it is U1 actually.

2024-04-11_203434

  1. Also, for .Name-part tooltip shows both types U1 and U2. I would expect to see only one type.

2024-04-11_203445

As far as I can see code compiles and runs correctly without runtime errors, IL doesn't mention U2 type besides declaration.

I suspect these problems are related but tell me if I should create separate issue for each one :)

Related information

  • .NET SDK 8.0.204
  • VS 17.9.6 and also Rider 2024.1, probably not specific to IDE.

BoundedChenn31 avatar Apr 11 '24 17:04 BoundedChenn31

The same thing also shows with Ionide in VS Code:

https://github.com/dotnet/fsharp/assets/14795984/ecb072fd-ad85-49a8-9bd9-cd54e6810ca8

brianrourkeboll avatar Apr 12 '24 18:04 brianrourkeboll

Noticed that the same code fails to compile with 7.0.202 SDK. Compiler treats u as U2 and doesn't see seq<U1 -> string> when deducing:

Error FS0193 : Type constraint mismatch. The type 
    'U2 -> string'    
is not compatible with type
    'U1 -> string'

Really hope that it's not a regression, I don't want to write fun (u: U1) -> u.Name again in the future :laughing:

BoundedChenn31 avatar Apr 19 '24 17:04 BoundedChenn31