Skip to content

Checker: fix overload cache key collisions - #21025

Open
auduchinok wants to merge 1 commit into
dotnet:mainfrom
auduchinok:checker-overloadCacheTyArgs
Open

auduchinok wants to merge 1 commit into
dotnet:mainfrom
auduchinok:checker-overloadCacheTyArgs

Conversation

@auduchinok

Copy link
Copy Markdown
Member

The overload resolution cache keyed a call by a summary of its argument types and candidates, so a call could get the method chosen for a different call. Which call was resolved first decided the result. This is flaky and sometimes leads to FS0193 in CI.

The key is now everything resolution reads, written as one exact token sequence; a call that cannot be written exactly is not cached. A hit checks the cached method again the way the full resolution found it, so it reports the same warnings as a miss.

@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

✅ Release notes checked


✅ Found changes and release notes in following paths:

Change path Release notes path Description
`src/Compiler` docs/release-notes/.FSharp.Compiler.Service/11.0.200.md

The overload resolution cache keyed a call by a summary of its argument types
and candidates, so a call could get the method chosen for a different call. It
missed explicit type arguments, the instantiation of the declaring type, method
type arguments already solved while checking the arguments, tuple and function
nesting, type parameters, units of measure, nullness and conversions declared
later in the file. A hit also returned the method without the warnings and the
trace a full resolution gives.

The key is now everything resolution reads, written as one exact token
sequence. A call that cannot be written exactly is not cached. A hit checks the
cached method again the way the full resolution found it, so it returns the
same warnings and trace, and falls back to full resolution if the method no
longer applies.

Types of the file being checked are keyed together with the number of members
and interfaces the file has published so far, and not cached while type
definitions are being established. A result is not stored when resolution
reported a diagnostic directly or looked up a conversion that depends on the
caller's access rights.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@auduchinok
auduchinok force-pushed the checker-overloadCacheTyArgs branch from d725514 to 5522900 Compare November 24, 2026 16:30

@abonie abonie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖🕵️ AI review — verify independently.


member _.AddType(ty: TType) =
if not ctx.IsRejected then
emitTType ctx ty

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖🕵️ Different anonymous-record types share this stamp — the cached obj overload makes the second call fail with FS0193.

// Compile as TypeEncodingLibā漢.dll
module CrossLibOne
let first = {| D = 1 |}

// Compile as TypeEncodingLib.dll
module CrossLibTwo
let second = {| ``∁ůD`` = 1 |}
type Overloaded =
    static member Pick(x: obj) = "object"
    static member Pick(x: {| ``∁ůD``: int |}) = 2

// Consumer referencing both DLLs
module CrossLibConsumer
let a: string = CrossLibTwo.Overloaded.Pick CrossLibOne.first
let b: int = CrossLibTwo.Overloaded.Pick CrossLibTwo.second

Both producer DLLs emit on base and PR. The exact base compiler also emits the consumer; this PR adds FS0193 at the second call. Both versions report the same existing FS3186 metadata warnings. These assembly/field-name combinations produce the same stamp despite different semantic types; encode the actual assembly identity and field names rather than their hashed stamp.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

2 participants