Skip to content

Values inside 'as' patterns are disposed multiple times #12300

Open
@auduchinok

Description

@auduchinok
let mutable isDisposed = false

let d = { new System.IDisposable with
            member x.Dispose() =
                printfn $"{isDisposed}"
                isDisposed <- true }

do
    use a as b = d
    ()

yields

False
True
val mutable isDisposed : bool = true
val d : System.IDisposable
val it : unit = ()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-Compiler-PatternMatchingpattern compilation, active patterns, performance, codegenBugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.

    Type

    Projects

    Status

    New

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions