Skip to content

Allow typed bindings(and!) in CE without parentheses #18682

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

Draft
wants to merge 35 commits into
base: main
Choose a base branch
from

Conversation

edgarfgp
Copy link
Contributor

@edgarfgp edgarfgp commented Jun 10, 2025

Description

Allow computation expression (CE) bindings (let!, use!, and!) to accept type annotations without requiring parentheses.

Continuation of #18508
Implements RFC FS-1329: fsharp/fslang-design#802

Checklist

  • Test cases added
  • Release notes entry updated

@edgarfgp edgarfgp changed the title Allow and bang typed bindings Allow and! typed bindings Jun 10, 2025
Copy link
Contributor

github-actions bot commented Jun 10, 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 changed the title Allow and! typed bindings Allow typed bindings(and!) in CE without parentheses Jun 10, 2025
Copy link
Member

@auduchinok auduchinok left a comment

Choose a reason for hiding this comment

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

@edgarfgp Thanks for this! Could you also cover error cases in the grammar, please? If unified with the let parsing, we could probably get a lot of recovery for free as well.

@@ -4107,6 +4107,22 @@ moreBinders:
let trivia = { AndBangKeyword = rhs parseState 1; EqualsRange = mEquals; InKeyword = Some mIn }
SynExprAndBang(spBind, $1, true, $2, $4, m, trivia) :: $6 }

| AND_BANG headBindingPattern opt_topReturnTypeWithTypeConstraints EQUALS typedSequentialExprBlock IN moreBinders %prec expr_let
Copy link
Member

Choose a reason for hiding this comment

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

At this point we should probably try to unify let and let! parsing rules and check whether it's a ! version or not in the type checker. As the first step it should be at least parse it in a unified manner and then create different tree nodes conditionally. But ideally it should be something like isComputed: bool flag that the type checker would inspect.

@edgarfgp Do you think it's feasible to unify the rules as part of this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you think it's feasible to unify the rules as part of this PR?

Agreed. I think as part of this PR I can try and I can try and unify the parsing rules for let, let! and and!.

Could you also cover error cases in the grammar, please?

Yeah I can add syntax tree test that show the parsing errors.

cc @T-Gro any objections ?

@github-project-automation github-project-automation bot moved this from New to In Progress in F# Compiler and Tooling Jun 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

2 participants