Skip to content

Conversation

edgarfgp
Copy link
Contributor

Description

Fixes #19005

Checklist

  • Test cases added
  • Release notes entry updated

Copy link
Contributor

❗ Release notes required

@edgarfgp,

Caution

No release notes found for the changed paths (see table below).

Please make sure to add an entry with an informative description of the change as well as link to this pull request, issue and language suggestion if applicable. Release notes for this repository are based on Keep A Changelog format.

The following format is recommended for this repository:

* <Informative description>. ([PR #XXXXX](https://github.com/dotnet/fsharp/pull/XXXXX))

See examples in the files, listed in the table below or in th full documentation at https://fsharp.github.io/fsharp-compiler-docs/release-notes/About.html.

If you believe that release notes are not necessary for this PR, please add NO_RELEASE_NOTES label to the pull request.

You can open this PR in browser to add release notes: open in github.dev

Change path Release notes path Description
src/Compiler docs/release-notes/.FSharp.Compiler.Service/10.0.100.md No release notes found or release notes format is not correct

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.

The naive approach of simply copying the type node doesn't look correct to me, because of how types of the bound expressions and the patterns rarely match.

Please let's not merge it until a proper explanation is provided.

Comment on lines 1928 to 1932
match typeAnnOpt with
| Some(ty, mTy) ->
// Apply the type annotation to the identifier expression to surface type errors on the annotation
SynExpr.Typed(SynExpr.Ident ident, ty, unionRanges ident.idRange mTy)
| None -> SynExpr.Ident ident
Copy link
Member

Choose a reason for hiding this comment

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

@edgarfgp Could you explain this logic in greater detail, please?

There're very tricky details related to the types in computation expression builder methods, so I think it would be nice if everyone could follow your thought process here.

Copy link
Contributor

Choose a reason for hiding this comment

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

It also seems to follow that such code will compile, even though it is erroneous.

open System

async {
    use! (x: string): IDisposable = async { return null }
    return x
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@auduchinok My current attempt is to move the annotation off the Bind lambda parameter to the value we pass to Using so we don't force Bind type parameter(We let Bind pick the right input type from overloads by leaving the lambda parameter untyped.), but we still type-check the user’s annotation and report errors. But as Alex shared this wont be enough. My goal here is to find the minimal fix for this issue. Not to redesign the ExprAsUseBang case.

@github-project-automation github-project-automation bot moved this from New to In Progress in F# Compiler and Tooling Oct 16, 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.

Specified type is not checked for use! binding

3 participants