Skip to content

Allow _ in async use! _ pattern (lift FS1228 restriction) #16343

@bent-rasmussen

Description

@bent-rasmussen

Is your feature request related to a problem? Please describe.

I am a bit surprised that use _ (discard) is valid, like in this code:

// okay
use _ = { new IDisposable with member _.Dispose() = printfn "disposed" }
// ...

...whereas use! _ is invalid, like in this code:

// error FS1228: 'use!' bindings must be of the form 'use! <var> = <expr>'
async {
    use! _ = Async.OnCancel (fun () -> printfn "disposed")
    // ...
}

I am also not getting good results when googling FS1288.

Describe the solution you'd like

I expect to be able to use the discard "pattern" (?) in both cases.

Perhaps this is more complicated to implement than it looks like at first glance.

Describe alternatives you've considered

I am currently using __ (double _), which is exactly what I used before use _ became valid code.

Additional context

None.

Metadata

Metadata

Assignees

Labels

Area-ComputationExpressionsEnd-to-end experience for computation expressions (except async and state machine compilation)Feature Request

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions