ionide-vscode-fsharp icon indicating copy to clipboard operation
ionide-vscode-fsharp copied to clipboard

Type inference tooltip gives incorrect result in the editor

Open bruno-cadorette opened this issue 7 years ago • 4 comments

Problem

I've found an issue with the type inference tooltip

Steps to reproduce

If I type the function in my editor:let compose (f: 'a -> int) g = f >> g, I get the type signature ('a -> int) -> (int -> 'a) -> 'a -> 'a0, which is wrong (the type of g should be (int -> 'a0))

Machine infos

  • Operating system: Windows_NT
  • Arch: x64
  • VSCode: 1.24.0
  • MSBuild version:
Microsoft (R) Build Engine version 15.7.179.6572 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

bruno-cadorette avatar Jun 13 '18 21:06 bruno-cadorette

fsharpi output is as follows:

  ~  fsharpi                                                                                      8644  10:58:06

Microsoft (R) F# Interactive version 4.1
Copyright (c) Microsoft Corporation. All Rights Reserved.

For help type #help;;

> let compose (f: 'a -> int) g = f >> g;;
val compose : f:('a -> int) -> g:(int -> 'a0) -> ('a -> 'a0)

So this is a problem with the compiler and should be raised upstream at https://github.com/Microsoft/visualfsharp

7sharp9 avatar Jul 31 '18 09:07 7sharp9

Maybe I was trigger happy, my eyes have difficulty doing the comparison...

7sharp9 avatar Jul 31 '18 10:07 7sharp9

Its probably some artefact of global numbering starting from a0 and works through sequentially, whereas you don't really present global numbering to the user so you re-label them to start with a through z.

I would of thought the compiler would of reported the signature to be:

val compose : f:('a -> int) -> g:(int -> 'b) -> ('a -> 'b)

7sharp9 avatar Jul 31 '18 10:07 7sharp9

I think its the fact you introduces 'a into scope that the compiler starts with an 'a0

> let compose (f: _ -> int) (g: int -> _)  = f >> g;;
val compose : f:('a -> int) -> g:(int -> 'b) -> ('a -> 'b)

7sharp9 avatar Jul 31 '18 10:07 7sharp9