Skip to content

Allow _ in use! bindings values - #18487

Merged
T-Gro merged 17 commits into
dotnet:mainfrom
edgarfgp:fix-16343
Apr 28, 2025
Merged

Allow _ in use! bindings values#18487
T-Gro merged 17 commits into
dotnet:mainfrom
edgarfgp:fix-16343

Conversation

@edgarfgp

@edgarfgpedgarfgp commented Apr 20, 2025

Copy link
Copy Markdown
Contributor

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 Erroruse! __ =new Disposable()// No Erroruse!(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 Erroruse! __ =new Disposable()// No Erroruse!(res1)=new Disposable()// No Erroruse!(___)=new Disposable()// No Erroruse! _ =new Disposable()// No Erroruse! [| 1 |] =new Disposable()// Error^^^^^^^return()}

Fixes#16343

Checklist

  • Test cases added
  • Release notes entry updated

@edgarfgpedgarfgp changed the title Allow _ in use! _ bindings valuesAllow _ in use! bindings valuesApr 20, 2025
@github-actions

github-actionsBot commented Apr 20, 2025

Copy link
Copy Markdown
Contributor

❗ Release notes required


✅ Found changes and release notes in following paths:

Change pathRelease notes pathDescription
src/Compilerdocs/release-notes/.FSharp.Compiler.Service/9.0.300.md
LanguageFeatures.fsidocs/release-notes/.Language/preview.md

# Conflicts:
#	docs/release-notes/.FSharp.Compiler.Service/9.0.300.md
#	docs/release-notes/.Language/preview.md
@edgarfgp
edgarfgpforce-pushed the fix-16343 branch 4 times, most recently from 44694b7 to 949ee66CompareApril 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 ownerApril 22, 2025 16:14
@edgarfgp

Copy link
Copy Markdown
ContributorAuthor

To avoid conflicts #18482 should be merged first.

Comment threadsrc/Compiler/Checking/Expressions/CheckComputationExpressions.fs Outdated
Comment threadsrc/Compiler/FSComp.txt Outdated
@T-Gro
T-Gro enabled auto-merge (squash) April 25, 2025 08:29
@github-project-automationgithub-project-automationBot moved this from New to In Progress in F# Compiler and ToolingApr 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
Copy Markdown
ContributorAuthor

Fixed the merged conflict and this is green again :)

Sign up for freeto 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

@edgarfgp@abonie@T-Gro