Skip to content

Conversation

evgTSV
Copy link
Contributor

@evgTSV evgTSV commented Oct 3, 2025

Enhance the F# compiler’s type checker to correctly support and validate nested field updates (with depth > 1) for both anonymous and records. Add tests to cover these scenarios, and perform minor refactoring.

Fixes #18940
Fixes #18062

Copy link
Contributor

github-actions bot commented Oct 3, 2025

❗ Release notes required

@evgTSV,

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

TcExprRecord cenv overallTy env tpenv (inherits, withExprOpt, synRecdFields, mWholeExpr)
| Some(SynExpr.LongIdent (_, lId, _, _), _) as Some withExpr ->
let lIds = lId.LongIdent
if lIds |> List.tryFind (fun id -> id.idText = "bind@") |> _.IsSome then
Copy link
Member

Choose a reason for hiding this comment

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

Depending on a specific compiler-generated name doesn't look like a correct approach. It's too easy to break it down the road with other changes and it looks as a wrong thing to depend on.

TcPossiblyPropagatingExprLeafThenConvert (fun ty -> isAnonRecdTy g ty || isTyparTy g ty) cenv overallTy env mWholeExpr (fun overallTy ->
TcAnonRecdExpr cenv overallTy env tpenv (isStruct, withExprOpt, unsortedFieldExprs, mWholeExpr)
)
| Some(SynExpr.LongIdent (_, lId, _, _), _) as Some withExpr ->
Copy link
Member

Choose a reason for hiding this comment

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

This looks somewhat ad-hoc. I think it would be better to find a better implementation for the code above.

@evgTSV evgTSV requested a review from auduchinok October 4, 2025 12:11
@edgarfgp
Copy link
Contributor

edgarfgp commented Oct 5, 2025

I think this might also fix #18062 ?

@evgTSV
Copy link
Contributor Author

evgTSV commented Oct 5, 2025

Yes, this fixes that issue too

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.

Nested field update doesn't type-check properly Copy and update record expression doesn't compile when the record comes from a function
3 participants