-
Notifications
You must be signed in to change notification settings - Fork 831
Closed
Labels
Description
I though when I had tried this in the past I had got some compiler error, but I'm either mistaken or maybe crafting my function in a different way? (The thought that maybe I was doing something dubious should had stop my inclination to do it, but that is neither here not there) Anyway the following code compiles, but creates invalid IL:
let f (x:byref<bool>) () =
x <- true
let mutable b = false
let ok () =
printfn "this is ok!"
f &b ()
printfn "%b" b
let notok () =
// System.Runtime.InteropServices.COMException: Field of ByRef type. (Exception from HRESULT: 0x801312E4)
printfn "never get here!"
let f' = f &b
f' ()
printfn "%b" b
ok ()
notok ()
It dies whilst the poor JIT is trying to deal with the notok with the exception as listed in that method..