I just noticed that the F# compiler permits mutable use bindings:
letdisp msg ={new System.IDisposable withmember__.Dispose()= printfn "%s" msg }lettest()=use mutable d = disp "foo"
d <- disp "bar"Running test will cause "bar" to be printed. This feels wrong and the sentiment was corroborated by the fact that C# explicitly prevents it:
using(MemoryStreamm=newMemoryStream()){m=null;}which produces the compiler error:
Error 1 Cannot assign to 'm' because it is a 'using variable'
I checked the F# spec, but couldn't find any explicit mention of mutable use bindings.
Is this a compiler bug then?
I just noticed that the F# compiler permits mutable use bindings:
Running
testwill cause "bar" to be printed. This feels wrong and the sentiment was corroborated by the fact that C# explicitly prevents it:which produces the compiler error:
I checked the F# spec, but couldn't find any explicit mention of mutable use bindings.
Is this a compiler bug then?