Skip to content

Conversation

@hamishknight
Copy link
Contributor

Make sure we set types for any nested VarDecls in UnresolvedPatternExprs to ensure we don't crash when attempting to solve the body.

…rgument

Make sure we set types for any nested VarDecls in UnresolvedPatternExprs
to ensure we don't crash when attempting to solve the body.
@hamishknight
Copy link
Contributor Author

@swift-ci please test

@hamishknight
Copy link
Contributor Author

@swift-ci please SourceKit stress test

if (CS.isArgumentIgnoredForCodeCompletion(expr)) {
// Make sure we invalidate any nested VarDecls to ensure the body
// VarDecl for a case statement still gets a type assigned.
expr->forEachUnresolvedVariable([&](VarDecl *VD) {
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 a more robust long-term solution here might be to determine whether arguments are effectively ignored during pre-check and replace each one with something like a placeholder expression (something we'd need to add) that would generate a type variable or maybe remove them outright (I think we added some logic to the matcher at some point to not add "missing argument" fixes for cases like that).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately this is made trickier by the fact that we populate the case body variables when we create the AST, so we can't just drop AST nodes to fix this since the case body variables are still accessible to name lookup and won't have types assigned. Maybe we can come up with a better way of handling this

Copy link
Contributor

Choose a reason for hiding this comment

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

We could do

 expr->forEachUnresolvedVariable([&](VarDecl *VD) { ... };

as part of pre-check removing of the expressions...

@hamishknight hamishknight merged commit a4eb591 into swiftlang:main Oct 27, 2025
6 checks passed
@hamishknight hamishknight deleted the invalidate-skipped branch October 27, 2025 14:32
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