-
Notifications
You must be signed in to change notification settings - Fork 830
Fix checking nested fields for records #18964
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
… tests, minor refactoring
❗ Release notes requiredCaution 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:
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
|
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 |
There was a problem hiding this comment.
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.
tests/FSharp.Compiler.ComponentTests/Language/CopyAndUpdateTests.fs
Outdated
Show resolved
Hide resolved
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 -> |
There was a problem hiding this comment.
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.
I think this might also fix #18062 ? |
Yes, this fixes that issue too |
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