Skip to content

Conversation

DedSec256
Copy link
Contributor

@DedSec256 DedSec256 commented Oct 15, 2025

Now there are several ways to annotate the binding:

  • Annotate the head pattern
let (x: int) = 1

Tree:

SynBinding(
    ...
    headPat = SynPat.Paren(
        pat = SynPat.Typed(
            pat = SynPat.Named(ident = SynIdent.SynIdent(ident = Ident("x")),
            targetType = SynType.LongIdent(SynLongIdent.SynLongIdent(id = [ Ident("int") ]))
        ),
    ),
    returnInfo = None
)
  • Annotate the binding return type
let x: int = 1

Tree:

SynBinding(
    headPat = SynPat.Named(ident = SynIdent.SynIdent(ident = Ident("x"))),
    returnInfo =
        Some(
            SynBindingReturnInfo.SynBindingReturnInfo(
                typeName = SynType.LongIdent(SynLongIdent.SynLongIdent(id = [ Ident("int") ]))
            )
        )
)

However, for annotated let! / and! / use! bindings the SynBindingReturnInfo is always None. Instead, a typed head pat is always produced as a part of the syntax tree, even if there was no annotated pattern in a source code.

This is inconsistent with simple let bindings and can create problems when handling typed let! / and! / use! binding

let! x: int = ...

in logic that relies on return type info.

This PR brings the syntax tree to a consistent view.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 15, 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/11.0.0.md

Copy link
Contributor

@edgarfgp edgarfgp left a comment

Choose a reason for hiding this comment

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

Thanks @DedSec256 .

@DedSec256 DedSec256 marked this pull request as ready for review October 15, 2025 18:02
@DedSec256 DedSec256 requested a review from a team as a code owner October 15, 2025 18:02
@DedSec256
Copy link
Contributor Author

It seems that the fix in the tree is not enough. Types in the new syntax are not checked.
#19005

@DedSec256
Copy link
Contributor Author

@edgarfgp, this PR currently does not fix type checking for use!, but only make related changes so as not to break the existing type check logic for let! / and! after fixing the tree.
I clarified it in case PR #19009 was closed for this reason.

@edgarfgp
Copy link
Contributor

@DedSec256 No worries. Im still planning to investigate a fix for #19005. But would be good to wait for this to be merged so I can use your changes.

^ Conflicts:
^	docs/release-notes/.FSharp.Compiler.Service/11.0.0.md
@DedSec256 DedSec256 force-pushed the ber,a/fixLetBangTree branch from be0afee to e5b5efd Compare October 23, 2025 17:25
@DedSec256
Copy link
Contributor Author

@T-Gro, could you please take a look?

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.

2 participants