Skip to content

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

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 38 commits into from
May 16, 2025

Conversation

edgarfgp
Copy link
Contributor

@edgarfgp edgarfgp commented Apr 26, 2025

Description

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

Fixes #10697

BEFORE

let f =
    async {
        let! (a: int) = async { return 1 } // Valid
        let! b: int = async { return 1 } // Error
        use! (a: int) = ...  //Error
        use! b: int = ... //Error
        return a
    }

AFTER

let f =
    async {
        let! (a: int) = ... // Valid
        let! b: int = ... // Valid
        return a
    }

Once #18487 is merged

let f =
    async {
        use! (a: int) = ...  // Valid
        use! b: int = ... // Valid
        return a
    }

Checklist

  • Test cases added
  • Release notes entry updated

Copy link
Contributor

github-actions bot commented Apr 26, 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/10.0.100.md
LanguageFeatures.fsi docs/release-notes/.Language/preview.md

@edgarfgp edgarfgp requested a review from auduchinok April 30, 2025 16:24
@edgarfgp
Copy link
Contributor Author

edgarfgp commented Apr 30, 2025

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: 
let x: 
use x:

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

Copy link
Member

@baronfel baronfel left a comment

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.

@edgarfgp edgarfgp marked this pull request as ready for review May 1, 2025 20:11
@edgarfgp edgarfgp requested a review from a team as a code owner May 1, 2025 20:11
@edgarfgp edgarfgp closed this May 12, 2025
@edgarfgp edgarfgp reopened this May 12, 2025
Copy link
Member

@T-Gro T-Gro left a comment

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-Gro May 15, 2025 19:46
@edgarfgp
Copy link
Contributor Author

@T-Gro Updated as requested

@T-Gro T-Gro merged commit 8b7bf60 into dotnet:main May 16, 2025
33 checks passed
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.

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