Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
bent-rasmussen opened this issue Nov 26, 2023 · 0 comments · May be fixed by #18189
Open

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

bent-rasmussen opened this issue Nov 26, 2023 · 0 comments · May be fixed by #18189
Assignees
Labels
Area-ComputationExpressions End-to-end experience for computation expressions (except async and state machine compilation) Feature Request
Milestone

Comments

@bent-rasmussen
Copy link

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.

@github-actions github-actions bot added this to the Backlog milestone Nov 26, 2023
@bent-rasmussen bent-rasmussen changed the title Allow _ in async "use! _" pattern (lift FS1228 restriction) Allow _ in async use! _ pattern (lift FS1228 restriction) Nov 27, 2023
@abonie abonie added Area-ComputationExpressions End-to-end experience for computation expressions (except async and state machine compilation) and removed Needs-Triage labels Aug 26, 2024
@edgarfgp edgarfgp self-assigned this Dec 30, 2024
@edgarfgp edgarfgp linked a pull request Dec 30, 2024 that will close this issue
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-ComputationExpressions End-to-end experience for computation expressions (except async and state machine compilation) Feature Request
Projects
Status: New
Development

Successfully merging a pull request may close this issue.

3 participants