Skip to content

Disallow recursive structs with lifted type parameters - #19031

Merged
T-Gro merged 4 commits into
dotnet:mainfrom
brianrourkeboll:recursive-generic-struct-types
Nov 3, 2025
Merged

Disallow recursive structs with lifted type parameters#19031
T-Gro merged 4 commits into
dotnet:mainfrom
brianrourkeboll:recursive-generic-struct-types

Conversation

@brianrourkeboll

@brianrourkebollbrianrourkeboll commented Oct 25, 2025

Copy link
Copy Markdown
Contributor

Description

Fixes#18993.
Fixes#6069.

  • Emit "error FS0954: This type definition involves an immediate cyclic reference through a struct field or inheritance relation" for generic struct types that recursively reference themselves but (infinitely) lift their generic type parameter.

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

  • Test cases added.
  • Release notes entry updated.

@github-actions

github-actionsBot commented Oct 25, 2025

Copy link
Copy Markdown
Contributor

❗ Release notes required


✅ Found changes and release notes in following paths:

Change pathRelease notes pathDescription
src/Compilerdocs/release-notes/.FSharp.Compiler.Service/11.0.0.md

Comment threadsrc/Compiler/Checking/CheckDeclarations.fs
@brianrourkeboll
brianrourkeboll marked this pull request as ready for review October 25, 2025 17:23
@brianrourkeboll
brianrourkeboll requested a review from a team as a code ownerOctober 25, 2025 17:23
@edgarfgp

Copy link
Copy Markdown
Contributor

I think this PR might also fix #6069 ?

@brianrourkeboll

Copy link
Copy Markdown
ContributorAuthor

I think this PR might also fix #6069 ?

Hmm yes, probably. I will add a test/tests for mutually-recursive structs.

@github-project-automationgithub-project-automationBot moved this from New to In Progress in F# Compiler and ToolingNov 3, 2025
@T-Gro
T-Gro merged commit 9670f60 into dotnet:mainNov 3, 2025
38 checks passed
@brianrourkeboll
brianrourkeboll deleted the recursive-generic-struct-types branch November 3, 2025 21:06
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Compilation fails to terminate for polymorphic recursion on value types Infinite loop on expanding cycle for struct types

3 participants

@brianrourkeboll@edgarfgp@T-Gro