Fix #16432: Report FS0039 only once for undefined type in inherit clause#19862
Open
T-Gro wants to merge 6 commits into
Open
Fix #16432: Report FS0039 only once for undefined type in inherit clause#19862T-Gro wants to merge 6 commits into
T-Gro wants to merge 6 commits into
Conversation
…f unknown type Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Multiple typecheck passes (EstablishTypeDefinitionCores FirstPass and SecondPass, plus Phase2AInherit's TcType/TcNewExpr) each emit the same FS0039 for an undefined base type in an 'inherit'/'interface inherit' clause, surfacing three identical diagnostics. Introduce a DedupInheritDiagnosticsLogger overlay scoped via UseTransformedDiagnosticsLogger to TcMutRecDefinitions. The dedup key is the formatted message of UndefinedName so duplicate FS0039s for the same identifier collapse to one while unrelated diagnostics, including FS0039 for distinct identifiers, pass through unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Adds a cenv-scoped `(range, idText)` dedup of `UndefinedName` diagnostics applied around Phase 1F inherit type checking and Phase 2A `Phase2AInherit` processing in CheckDeclarations.fs. Resolves the triple-reporting in #16432 without changing the surface API. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Switch reportedUndefinedNames to ConcurrentDictionary<struct (range * string), unit> for consistency with the sibling argInfoCache field and to be defensive against any future parallel cenv use. - Forward CheckForRealErrorsIgnoringWarnings to the wrapped logger so the InheritDedupDiagnosticsLogger is a faithful pass-through for everything other than the intended UndefinedName dedup. - Document the rationale for unwrapping only WrappedError in isDuplicateUndefinedName. Expert reviewer item 1 (merging suggestions from later UndefinedName into the first) intentionally not applied: in the inherit-clause case the colliding diagnostics carry identical suggestion sets, and merging would couple this site to NameResolution.AddResults internals. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
❗ Release notes required
|
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
auduchinok
reviewed
May 29, 2026
Comment on lines
+56
to
+58
| type private InheritDedupDiagnosticsLogger | ||
| (seen: ConcurrentDictionary<struct (range * string), unit>, inner: DiagnosticsLogger) = | ||
| inherit DiagnosticsLogger("InheritDedupDiagnosticsLogger") |
Member
There was a problem hiding this comment.
@T-Gro Can we find out why the error is reported twice in the first place? It should probably not be raised/committed multiple times, and the results should flow between the stages?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #16432 — When a class inherit clause references an undefined base type, the compiler previously reported FS0039 three times (once for each type-checking pass). This PR deduplicates that diagnostic so only one error is emitted.
Changes
Testing