fsharp
fsharp copied to clipboard
Improved error message: `use y = fixed x` does not compile inside computation expressions

#nowarn "9"
open System
type TestCaseBuilder() =
member __.Using(disposable: IDisposable, f) =
try
f disposable
finally
match disposable with
| null -> ()
| disp -> disp.Dispose()
member __.Combine(f1, f2) = f2(); f1
member __.Zero() = ()
member __.Delay f = f
member __.Run f = f
let test = TestCaseBuilder()
[<EntryPoint>]
let main argv =
let x = [|1|]
use y = fixed x
test {
let x = [|1|]
let y = fixed x
use z = fixed x
()
}
|> ignore
0
I'm ok with this limitation, the interaction between the two features would almost always be unsound.
This should be re-opened to track giving a useful diagnostic.
Re-opening since there's an opportunity for a better diagnostic here, since the current error message is misleading