Compiling and executing the code
type Foo() =
static let test (t : 'T) : 'T list =
let b = new Bar<'T>(t)
[b.Value]
static member Test(t : int) = test t
and Bar<'T>(value : 'T) =
member __.Value = value
printfn "%A" (Foo.Test 42)
Results in a segmentation fault. Peverify output:
[IL]: Error: [C:\Users\eirik.tsarpalis\Desktop\test.exe : Test+Foo::test[T]][offset 0x00000001][found (unboxed) 'T'][expected ref 'System.Object'] Unexpected type on the stack.
[IL]: Error: [C:\Users\eirik.tsarpalis\Desktop\test.exe : Test+Foo::test[T]][offset 0x00000017][found ref 'Microsoft.FSharp.Collections.FSharpList`1[System.Object]'][expected ref 'Microsoft.FSharp.Collections.FSharpList`1[T]'] Unexpected type on the stack.
2 Error(s) Verifying test.exe
Place Bar<'T> declaration on top of Foo.
Windows 10, VS 15.4, Desktop CLR
It seems that the type checker is erroneously associating the two 'T variables in Bar and test. If I try to rename either of the two letters, a compiler warning will appear.
@eiriktsarpalis Thanks for this, I'll take a look
@eiriktsarpalis Proposed fix https://github.com/Microsoft/visualfsharp/pull/4077/
This has been merged and fixed
Most helpful comment
@eiriktsarpalis Proposed fix https://github.com/Microsoft/visualfsharp/pull/4077/