Skip to content

[Sema] Fix variable invalid optional chaining in if context diagnostic #63845

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
Feb 23, 2023

Conversation

LucianoPAlmeida
Copy link
Contributor

In constraint generation a RemoveUnwrap is recorded when adding OptionalObject for BindOptionalExpr but when adding contextual constraint and attempting to add the contextual conversion constraint we end up in attempting repairViaOptionalUnwrap which succeed because there is a RemoveUnwrap already but returns false because the fix was recorded on a previous constraint and is not on conversionsAndFixes list. This leaves the conversion constraint as failedConstraint and solver stops without being able to form a solution and produce diagnostic.
The fix is simply assume that if repairViaOptionalUnwrap is successful we assume fixed in repairFailure already because it either record a fix or bail because there is a fix already.

Resolves #63796

@LucianoPAlmeida
Copy link
Contributor Author

@swift-ci Please smoke test

@LucianoPAlmeida
Copy link
Contributor Author

@swift-ci Please smoke test MacOS Platform

Copy link
Contributor

@xedin xedin left a comment

Choose a reason for hiding this comment

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

Oops, thank you!

@xedin xedin merged commit 92ad107 into swiftlang:main Feb 23, 2023
@LucianoPAlmeida LucianoPAlmeida deleted the variable-question-condition branch February 25, 2023 19:07
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.

Incorrect diagnostic when using ? in a condition context
2 participants