Skip to content

[CodeCompletion] Fix a crash in solver-based keypath completion #39226

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

Merged
merged 1 commit into from
Sep 20, 2021

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Sep 9, 2021

Fix a crash that occurred if no type binding could be found for the key path’s base type. I wasn’t able to find a test case that reproduces this issue.

Fixes rdar://81408525

Fix a crash that occurred if no type binding could be found for the key path’s base type. I wasn’t able to find a test case that reproduces this issue.

Fixes rdar://81408525
@ahoppen ahoppen requested a review from bnbarham September 9, 2021 12:08
@ahoppen
Copy link
Member Author

ahoppen commented Sep 9, 2021

@swift-ci Please smoke test

@@ -1303,25 +1303,28 @@ void KeyPathTypeCheckCompletionCallback::sawSolution(
// to look up type variables by their locators.
auto RootLocator =
S.getConstraintLocator(KeyPath, {ConstraintLocator::KeyPathRoot});
auto BaseVariableType =
auto BaseVariableTypeBinding =
Copy link
Contributor

Choose a reason for hiding this comment

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

This is very strange, the only reason why root is not in the bindings is key path isn't in scope of the solution since solution always records all of the type variables present in the constraint system...

Copy link
Member Author

Choose a reason for hiding this comment

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

My gut feeling was that it’s because the key path was skipped due to invalid code inside result builders. Do you think that might be the cause?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hm, maybe if part of the statement is skipped...

@ahoppen ahoppen merged commit f86f86e into swiftlang:main Sep 20, 2021
@ahoppen ahoppen deleted the pr/fix-keypath-completion-crash branch September 20, 2021 14:38
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