FSharp.TypeProviders.SDK icon indicating copy to clipboard operation
FSharp.TypeProviders.SDK copied to clipboard

Promote mutables to refs when captured by closures

Open kevmal opened this issue 5 years ago • 0 comments

Need to check on the erased case. But for the generated case

<@
    let mutable a = 0
    let f() = a <- a + 1
    f()
    a
@>

will return 0. In the short term there should at least be an error.

Otherwise perhaps the best place to fix this would be in QuotationSimplifier. Each mutable let could traverse down its body to check for references and then rewrite the Expr with a ref type if needed.

kevmal avatar Sep 10 '19 17:09 kevmal