Skip to content

Fix capture checker crash when mapping a Var capture set - #26667

Open
Linyxus wants to merge 1 commit into
scala:mainfrom
dotty-staging:fix-cc-dependent-any-var
Open

Fix capture checker crash when mapping a Var capture set#26667
Linyxus wants to merge 1 commit into
scala:mainfrom
dotty-staging:fix-cc-dependent-any-var

Conversation

@Linyxus

@Linyxus Linyxus commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

A dependent capture set such as {any, f} becomes a Union variable containing any when f is instantiated with an argument whose capture set is still a variable. When such a var is later mapped by a BiTypeMap under withNoVarsMapped (e.g. GlobalCapToLocal in CheckCaptures.recheckArg), the map changes existing elements, which tripped the assertion in CaptureSet.map that required the map to be element-identity in this mode.

Fixes #26649.

Have you relied on LLM-based tools in this contribution?

Yes, the crash was investigated and fixed by Kimi K3. I checked the changes with my brain. It looks reasonable to me, but I am no way an expert in capture inference.

How was the solution tested?

New automated tests

…Local

A dependent capture set such as `{any, f}` becomes a `Union` variable
containing `any` when `f` is instantiated with an argument whose capture
set is still a variable. When such a var is later mapped by a BiTypeMap
under `withNoVarsMapped` (e.g. `GlobalCapToLocal` in
`CheckCaptures.recheckArg`), the map changes existing elements, which
tripped the assertion in `CaptureSet.map` that required the map to be
element-identity in this mode.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dependent function types crash the capture checker

1 participant