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

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: New
Development

Successfully merging this pull request may close these issues.

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