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.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

2 participants