Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
edgarfgp wants to merge48 commits intodotnet:main
base:main
Choose a base branch
Loading
fromedgarfgp:allow-and-bang-typed-bindings

Conversation

edgarfgp
Copy link
Contributor

@edgarfgpedgarfgp commentedJun 10, 2025
edited
Loading

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

Introduces significant grammar unification:

  • New parsing rules:bindingPatternWithOptType andceBindingCore
  • New helper functions:mkLetExpression andmkAndBang
  • Renamed language feature toAllowTypedLetUseAndBang

The above rule unification will allow us to remove in a separate PRLetOrUseBang, adding boolenisComputed property(true for let!/use!, false for let/use) toLetOrUse.

typeSynExpr=| LetOrUseof         isRecursive: bool*         isUse: bool*         isComputed: bool*// NEW: true for let!/use!, false for let/use        bindings: SynBinding list*         body: SynExpr*         range: range*         trivia: SynExprLetOrUseTrivia

Checklist

  • Test cases added
  • Release notes entry updated

brianrourkeboll, TheAngryByrd, mnebes, ijklam, and smoothdeveloper reacted with heart emoji
edgarfgpand others added25 commitsApril 23, 2025 15:27
@edgarfgpedgarfgp changed the titleAllow and bang typed bindingsAllowand! typed bindingsJun 10, 2025
@github-actionsGitHub Actions
Copy link
Contributor

github-actionsbot commentedJun 10, 2025
edited
Loading

❗ 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

@edgarfgpedgarfgp changed the titleAllowand! typed bindingsAllow typed bindings(and!) in CE without parenthesesJun 10, 2025
Copy link
Member

@auduchinokauduchinok 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 thelet parsing, we could probably get a lot of recovery for free as well.

@edgarfgpedgarfgpforce-pushed theallow-and-bang-typed-bindings branch from11a44ca to2e074f0CompareJune 19, 2025 14:22
@edgarfgpedgarfgpforce-pushed theallow-and-bang-typed-bindings branch from2e074f0 toc03a338CompareJune 19, 2025 19:07
@edgarfgpedgarfgpforce-pushed theallow-and-bang-typed-bindings branch fromfdd8074 to9e50380CompareJuly 6, 2025 16:22
@edgarfgp
Copy link
ContributorAuthor

/azp run

@azure-pipelinesAzure Pipelines
Copy link

Commenter does not have sufficient privileges for PR 18682 in repo dotnet/fsharp

@edgarfgpedgarfgpforce-pushed theallow-and-bang-typed-bindings branch from009b91b to02fecdfCompareJuly 12, 2025 20:12
@edgarfgpedgarfgpforce-pushed theallow-and-bang-typed-bindings branch from34ec912 tofd7e890CompareJuly 12, 2025 21:19
@edgarfgpedgarfgp requested a review fromCopilotJuly 15, 2025 01:45
Copy link

@CopilotCopilotAI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements support for allowing type annotations onlet!,use!, andand! bindings in computation expressions without requiring parentheses, in line with RFC FS-1329.

  • Grammar and AST updates introduce unified parsing rules (bindingPatternWithOptType,ceBindingCore) and new helper functions (mkLetExpression,mkAndBang) to build the correct AST nodes.
  • Language feature renamed toAllowTypedLetUseAndBang and its usage updated in both the feature registry and computation expression checker.
  • Extensive updates to parser-service tests, component tests, and release notes ensure coverage of the new scenarios and adjust expected diagnostics.

Reviewed Changes

Copilot reviewed 86 out of 86 changed files in this pull request and generated no comments.

Show a summary per file
FileDescription
tests/service/data/SyntaxTree/SynType/Typed UseBang.fs / .fs.bslUpdated parser-service test cases for typeduse! scenarios, adjusting expected parse errors and AST shapes.
tests/service/data/SyntaxTree/SynType/Typed LetBang AndBang.fs / .fs.bslExtended test suite across 18+ variations to cover typedlet!,and!, patterns, lists, tuples, unions, etc.
tests/service/data/SyntaxTree/Pattern/Typed - Missing type*.fs.bslAdded missingExpecting type parse errors to existing pattern tests.
tests/service/data/SyntaxTree/Member/Member 13.fs.bslInjectedExpecting type parse error for incomplete member definitions.
tests/service/data/SyntaxTree/Expression/Yield* / Return*!*.fs.bslAddedExpecting type parse errors to yield/return tests for completeness.
tests/service/data/SyntaxTree/ComputationExpression/SynExprAndBangRange.fs.bslFixed ranges forSynExprAndBang to reflect trimmed spans after grammar changes.
tests/FSharp.Compiler.ComponentTests/Language/ComputationExpressionTests.fsExtended CE component tests to coverand! type-annotation behavior and adjusted diagnostic positions.
tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/UseBindings/*.fsAdjusted diagnostic column spans inUseBangBindingsVersion9 tests to match new grammar.
src/Compiler/pars.fsyIntroducedbindingPatternWithOptType andceBindingCore, updatedand! grammar rules and error recovery.
src/Compiler/SyntaxTree/ParseHelpers.fsiAddedmkLetExpression andmkAndBang signatures; replaced oldmkLocalBindings.
src/Compiler/SyntaxTree/ParseHelpers.fsImplementedmkLetExpression andmkAndBang, removedmkLocalBindings, unified binding AST creation.
src/Compiler/Facilities/LanguageFeatures.fsi / .fsRenamed feature flag toAllowTypedLetUseAndBang and updated version support.
src/Compiler/Checking/Expressions/CheckComputationExpressions.fsUpdated computation expression checker to use the newAllowTypedLetUseAndBang language feature.
docs/release-notes/.Language/preview.mdAdded entry for preview support ofand! type annotations without parentheses.
docs/release-notes/.FSharp.Compiler.Service/10.0.100.mdUpdated release notes to includeand! in the feature description.
Comments suppressed due to low confidence (2)

src/Compiler/SyntaxTree/ParseHelpers.fs:871

  • [nitpick] Consider adding XML documentation comments for mkAndBang in the .fsi file to explain its parameters and use in computation expressions.
let mkAndBang (mKeyword: range, pat: SynPat, rhs: SynExpr, mWhole: range, mEquals: range, mIn: range option) =

src/Compiler/pars.fsy:3523

  • [nitpick] It may help to expand this comment with an example of how bindingPatternWithOptType interacts with ceBindingCore and the newand! rules, improving future maintainability.
// This rule unifies the pattern parsing for both regular 'let' bindings and (let!, use!, and!)

@edgarfgpedgarfgp marked this pull request as ready for reviewJuly 15, 2025 03:02
@edgarfgpedgarfgp requested a review froma team as acode ownerJuly 15, 2025 03:02
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

Copilot code reviewCopilotCopilot left review comments

@T-GroT-GroAwaiting requested review from T-Gro

@auduchinokauduchinokAwaiting requested review from auduchinok

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Labels
None yet
Projects
Status: In Progress
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@edgarfgp@auduchinok@T-Gro

[8]ページ先頭

©2009-2025 Movatter.jp