Skip to content

Allow let! and use! binding with type annotation without parentheses. - #18508

Merged
T-Gro merged 38 commits into
dotnet:mainfrom
edgarfgp:fix-10697
May 16, 2025
Merged

Allow let! and use! binding with type annotation without parentheses.#18508
T-Gro merged 38 commits into
dotnet:mainfrom
edgarfgp:fix-10697

Conversation

@edgarfgp

@edgarfgpedgarfgp commented Apr 26, 2025

Copy link
Copy Markdown
Contributor

Description

Allow let! and use! binding with type annotation without parentheses.

Fixes#10697

BEFORE

letf=async{let!(a:int)=async{return1}// Validlet!b:int =async{return1}// Erroruse!(a:int)=...//Erroruse! b:int =...//Errorreturn a
}

AFTER

letf=async{let!(a:int)=...// Validlet!b:int =...// Validreturn a
}

Once #18487 is merged

letf=async{use!(a:int)=...// Validuse! b:int =...// Validreturn a
}

Checklist

  • Test cases added
  • Release notes entry updated

@github-actions

github-actionsBot commented Apr 26, 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/10.0.100.md
LanguageFeatures.fsidocs/release-notes/.Language/preview.md

Comment threadsrc/Compiler/pars.fsy Outdated
Comment threadsrc/Compiler/pars.fsy Outdated
@edgarfgp

edgarfgp commented Apr 30, 2025

Copy link
Copy Markdown
ContributorAuthor

It might be interesting in a follow up PR to add error recovery for cases where we have a headBindingPattern COLON error

let!x:use! stream:letx:use x:

Where we can use reportParseErrorAt mColon (FSComp.SR.parsExpectingType())

@baronfelbaronfel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love the depth of test coverage here.

@edgarfgpedgarfgp reopened this May 12, 2025

@T-GroT-Gro left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really a nice addition @edgarfgp 👍 .

I think this is a change where we would be better with having a languageFeature guard with recovery.

Reason is, people might be having mismatched SDKs locally vs CI.

This change would allow code to pass locally, but then surprisingly fail parsing when ran on CI with a different SDK version.

LanguageVersion will cover for that scenario.

@edgarfgp
edgarfgp requested a review from T-GroMay 15, 2025 19:46
@edgarfgp

Copy link
Copy Markdown
ContributorAuthor

@T-Gro Updated as requested

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.

let! binding with type annotation without parentheses yields error FS0010: Unexpected symbol ':' in expression

4 participants

@edgarfgp@baronfel@brianrourkeboll@T-Gro