Skip to content

Allow _ in use! bindings values #18487

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

Merged
merged 17 commits into from
Apr 28, 2025
Merged

Allow _ in use! bindings values #18487

merged 17 commits into from
Apr 28, 2025

Conversation

edgarfgp
Copy link
Contributor

@edgarfgp edgarfgp commented Apr 20, 2025

Description

Currently if we use any pattern that is not Named or LongIdent it errors miserably pointing at the use! range.

Also it does not allow to wrap patterns In parens(I don't see the point in restricting use e.g. (x), (__), (_).)

So in this PR:

  • Allows Named or LongIdent and Wild(only in preview) to be wrapped in parens
  • Updates the error range to use the pat range instead of the use! range

BEFORE

counterDisposable {
    use! res = new Disposable() // No Error
    use! __ = new Disposable() // No Error
    use! (res1) = new Disposable() // Error
    ^^^^
    use! (___) = new Disposable() // Error
    ^^^^
    use! _ = new Disposable() // Error
    ^^^^
    use! [| 1 |] = new Disposable() // Error
    ^^^^
    return ()
}

AFTER

counterDisposable {
    use! res = new Disposable() // No Error
    use! __ = new Disposable() // No Error
    use! (res1) = new Disposable() // No Error
    use! (___) = new Disposable() // No Error
    use! _ = new Disposable() // No Error
    
    use! [| 1 |] = new Disposable() // Error
         ^^^^^^^
    return ()
}

Fixes #16343

Checklist

  • Test cases added
  • Release notes entry updated

@edgarfgp edgarfgp changed the title Allow _ in use! _ bindings values Allow _ in use! bindings values Apr 20, 2025
Copy link
Contributor

github-actions bot commented Apr 20, 2025

❗ Release notes required


✅ Found changes and release notes in following paths:

Change path Release notes path Description
src/Compiler docs/release-notes/.FSharp.Compiler.Service/9.0.300.md
LanguageFeatures.fsi docs/release-notes/.Language/preview.md

# Conflicts:
#	docs/release-notes/.FSharp.Compiler.Service/9.0.300.md
#	docs/release-notes/.Language/preview.md
@edgarfgp edgarfgp force-pushed the fix-16343 branch 4 times, most recently from 44694b7 to 949ee66 Compare April 22, 2025 05:41
@edgarfgp edgarfgp marked this pull request as ready for review April 22, 2025 16:14
@edgarfgp edgarfgp requested a review from a team as a code owner April 22, 2025 16:14
@edgarfgp
Copy link
Contributor Author

To avoid conflicts #18482 should be merged first.

@T-Gro T-Gro enabled auto-merge (squash) April 25, 2025 08:29
@github-project-automation github-project-automation bot moved this from New to In Progress in F# Compiler and Tooling Apr 25, 2025
# Conflicts:
#	src/Compiler/Checking/Expressions/CheckComputationExpressions.fs
auto-merge was automatically disabled April 25, 2025 12:07

Head branch was pushed to by a user without write access

@edgarfgp
Copy link
Contributor Author

Fixed the merged conflict and this is green again :)

@T-Gro T-Gro merged commit 9995898 into dotnet:main Apr 28, 2025
33 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in F# Compiler and Tooling Apr 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Allow _ in async use! _ pattern (lift FS1228 restriction)
3 participants