Skip to content

[DNM] [CS] Handle holes in mergeEquivalenceClasses #83724

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

hamishknight
Copy link
Contributor

No description provided.

@hamishknight
Copy link
Contributor Author

@swift-ci please test

@hamishknight
Copy link
Contributor Author

@swift-ci please test source compatibility

let x = foo([], i)
// expected-error@-1 {{generic parameter 'T' could not be inferred}}
// expected-error@-2 {{cannot convert value of type '[Any]' to expected argument type '_.Type'}}
// FIXME: The above should say `T.Type` not `_.Type` ^
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is a bug in FailureDiagnostic::resolveType, might be easy to fix.

Copy link
Contributor Author

@hamishknight hamishknight Aug 14, 2025

Choose a reason for hiding this comment

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

Yeah the issue is that we need the hole's locator, but that currently requires iterating over the equivalence class, which we don't have in the Solution. So either we need to stick the locator on the type variable itself as an extra bit of state, or stick a mapping in the Solution

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I see.

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we just make that transformation part of ConstraintSystem::finalize then?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The actual type being diagnosed is part of the fix though, right? Unless I'm misunderstanding what you mean by transformation

Copy link
Contributor

Choose a reason for hiding this comment

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

We never want to print type variables so maybe replacing them with an underlying generic parameter should be done as part of forming a solution instead of delaying it to diagnostics like we do right now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah right I see what you're saying, let me give that a try

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.

2 participants