-
Notifications
You must be signed in to change notification settings - Fork 833
Disallow recursive structs with lifted type parameters #19031
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?
Disallow recursive structs with lifted type parameters #19031
Conversation
❗ Release notes required
|
| // This type (type instance) has been seen before, so no need to collect the same edges again (and avoid loops!) | ||
| List.exists (typeEquiv g ty) doneTypes | ||
| // This tycon is the outer tycon with a lifted generic argument, e.g., `'a list`. | ||
| || not (isNil doneTypes) && tryTcrefOfAppTy g ty |> ValueOption.bind _.TryDeref |> ValueOption.exists ((===) tycon) |
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.
We only do this check when doneTypes is not empty because we need to collect the self-referential edge once.
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.
Separately, I don't think I fully understand when it is safe to access EntityRef.Deref. Tell me if TryDeref is unnecessary here and I will simplify it.
tests/FSharp.Compiler.ComponentTests/Conformance/Types/RecordTypes/RecordTypes.fs
Show resolved
Hide resolved
|
I think this PR might also fix #6069 ? |
Hmm yes, probably. I will add a test/tests for mutually-recursive structs. |
Description
Fixes #18993.
Fixes #6069.
I don't know if "lifting" is the correct term for this; let me know if there is a more correct term or phrase that I should use to describe this in the comment and the tests. Maybe nested app ty/type application?
Checklist