Skip to content

Detect recursive inline bindings and emit FS3888 diagnostic#19803

Open
T-Gro wants to merge 4 commits into
mainfrom
fix/issue-17991
Open

Detect recursive inline bindings and emit FS3888 diagnostic#19803
T-Gro wants to merge 4 commits into
mainfrom
fix/issue-17991

Conversation

@T-Gro
Copy link
Copy Markdown
Member

@T-Gro T-Gro commented May 25, 2026

Fixes #17991

Summary

Recursive use of an inline function or member now produces a clear error (FS3888: The value '{0}' is declared inline but is used recursively. Recursive inline definitions are not supported.) instead of the misleading FS1113/FS1114 errors that appeared previously.

Changes

  • New diagnostic FS3888 added to FSComp.txt plus all localization xlf files.
  • Detection in TcLetrecBindings (CheckDeclarations.fs): after collecting let rec bindings, any binding marked inline that participates in a recursive cycle now triggers FS3888 at type-check time.
  • Detection in TcMutRecBindings_Phase2C (CheckExpressions.fs): extends the same check to class members via cycle detection through inline-only edges, avoiding false positives on non-recursive inline property accessors.
  • TypedTree.fs/.fsi: added SetInlineInfo mutator on Val to allow clearing the inline flag after the diagnostic is issued (so downstream phases don't crash).
  • Tests (RecursiveSafetyAnalysis.fs): new test cases for recursive inline let rec bindings and recursive inline members, verifying the diagnostic text and error code.

T-Gro and others added 4 commits May 25, 2026 12:33
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ostic

Extend recursive-inline detection to class members via TcMutRecBindings_Phase2C,
using cycle detection through inline bindings only so non-recursive inline
member accesses (e.g. inline get/set referencing other plain members) are not
false-positives.

Refs #17991

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

❗ Release notes required

@T-Gro,

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/11.0.100.md No release notes found or release notes format is not correct

@github-actions github-actions Bot added the AI-Tooling-Check-Bypassed Tooling check: non-fork PR, not diff-analyzed label May 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI-Tooling-Check-Bypassed Tooling check: non-fork PR, not diff-analyzed

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

Recursive use of inline member should produce better diagnostic

1 participant