Skip to content

Instantly share code, notes, and snippets.

@eiriktsarpalis
Created October 29, 2014 18:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eiriktsarpalis/ec4a108444a91c0e7e8f to your computer and use it in GitHub Desktop.
Save eiriktsarpalis/ec4a108444a91c0e7e8f to your computer and use it in GitHub Desktop.
F# bug reproduction
type Foo<'T>(bar (* add explicit type annotation to fix *), value : 'T) =
member __.Value = value
and Bar () as self =
let create (x : 'T) : Foo<'T> =
printfn "%O" typeof<'T>
new Foo<'T>(self, x)
member __.Create<'T>(x : 'T) : Foo<'T> = create x
Bar().Create 1
@dsyme
Copy link

dsyme commented Oct 29, 2014

Yes, that's a bug. Thanks!

@dsyme
Copy link

dsyme commented Jan 29, 2015

Here's the peverify error:

[IL]: Error: [C:\GitHub\dsyme\visualfsharp\a.exe : A+Bar::create[T]][offset 0x00 000037][found (unboxed) 'T'][expected ref 'System.Object'] Unexpected type on th e stack.
[IL]: Error: [C:\GitHub\dsyme\visualfsharp\a.exe : A+Bar::create[T]][offset 0x0000003C][found ref 'A+Foo`1[System.Object]'][expected ref 'A+Foo`1[T]'] Unexpected type on the stack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment