Skip to content

Fix FS1182 not reported for unused let functions in class types#19805

Open
T-Gro wants to merge 2 commits into
mainfrom
fix/issue-13849
Open

Fix FS1182 not reported for unused let functions in class types#19805
T-Gro wants to merge 2 commits into
mainfrom
fix/issue-13849

Conversation

@T-Gro
Copy link
Copy Markdown
Member

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

Summary

Fix #13849: FS1182 ("unused binding") warning was not reported for unused let function bindings inside class types.

Problem

Class-let function bindings are promoted to compiler-generated members, which sets IsCompiledAsTopLevel=true. The reportIfUnused helper in CheckIncrementalClasses.IncrClassReprInfo.ChooseRepresentation had a not v.IsCompiledAsTopLevel guard that silently suppressed FS1182 for these bindings.

Fix

Removed the not v.IsCompiledAsTopLevel guard from the local reportIfUnused helper. This helper is scoped to class-binding representation choice, so the change cannot introduce module-level false positives.

Test

Added test cases in tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/warnon/warnon.fs verifying that FS1182 is correctly emitted for unused let functions in class types.

Fixes #13849

T-Gro and others added 2 commits May 25, 2026 21:20
Removed the 'not v.IsCompiledAsTopLevel' guard in the local 'reportIfUnused' helper inside CheckIncrementalClasses.IncrClassReprInfo.ChooseRepresentation. Class-let function bindings are promoted to compiler-generated members, which sets IsCompiledAsTopLevel=true and previously silently suppressed FS1182. The helper is local to class-binding representation choice, so this change cannot introduce module-level false positives.

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

❗ Release notes required


✅ Found changes and release notes in following paths:

Warning

No PR link found in some release notes, please consider adding it.

Change path Release notes path Description
src/Compiler docs/release-notes/.FSharp.Compiler.Service/11.0.100.md No current pull request URL (#19805) found, please consider adding it

@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.

Unused binding warning isn't reported for recursive binding in a type

1 participant