[Sema] Avoid null-node crash for invalid closure parameter wrappers#87494
Open
Flamki wants to merge 1 commit intoswiftlang:mainfrom
Open
[Sema] Avoid null-node crash for invalid closure parameter wrappers#87494Flamki wants to merge 1 commit intoswiftlang:mainfrom
Flamki wants to merge 1 commit intoswiftlang:mainfrom
Conversation
Invalid property wrapper declarations on closure parameters can leave wrapper-synthesized local vars absent. Avoid assigning types to missing wrapper vars during closure constraint resolution and solution application, and skip wrapper-specific constraint generation in that case.\n\nAdd a regression test for swiftlang#87479 covering a global closure parameter annotated with an invalid property wrapper.
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This fixes an assertion crash when a closure parameter uses an invalid property wrapper.
For code like:
the compiler was asserting in
ConstraintSystem::setTypebecause closure wrapper-synthesized vars could be missing, butresolveClosureunconditionally attempted to assign types to them.What changed
ConstraintSystem::resolveClosure(lib/Sema/CSSimplify.cpp):backingVar,wrappedValueVar).applySolutionToClosurePropertyWrappers(lib/Sema/CSSyntacticElement.cpp):test/Sema/property_wrapper_parameter_invalid.swiftfor Usage of property wrapper in global closure parameter causes assertion failure #87479.Why this approach
Invalid wrapper declarations are already diagnosed by declaration checking. In this path we only need to avoid crashing while closure constraints are being resolved/applied.
Before / After
Before:
Cannot set type information on null node).After:
Issue
Fixes #87479