Skip to content

AST: don't propagate null Type from invalid associated conformance #88873

Merged
airspeedswift merged 1 commit into
swiftlang:mainfrom
airspeedswift:packconformance-getassociatedconformance-invalid-pattern
May 7, 2026
Merged

AST: don't propagate null Type from invalid associated conformance #88873
airspeedswift merged 1 commit into
swiftlang:mainfrom
airspeedswift:packconformance-getassociatedconformance-invalid-pattern

Conversation

@airspeedswift

Copy link
Copy Markdown
Member

When a pattern conformance in the pack is invalid (e.g. its underlying conformance failed because of a prior diagnostic), getAssociatedConformance returned an invalid ProtocolConformanceRef whose getType() is null. The null type was pushed into packElements and tripped an assertion in PackType::get. Substitute ErrorType for the null so substitution can complete and the existing diagnostics surface to the user.

Fixes #88434.

@airspeedswift

Copy link
Copy Markdown
Member Author

@swift-ci please smoke test

@slavapestov

Copy link
Copy Markdown
Contributor

I would prefer check the conformance first, like assocConformance ? assocConformance.getType() : ErrorType(…)

We should probably fix the representation of invalid conformances to store a type at some point (today the invalid conformance is a singleton, literally a null pointer), since this sort of workaround has come up in several places already.

@airspeedswift airspeedswift force-pushed the packconformance-getassociatedconformance-invalid-pattern branch from 8dade2c to 5f5e499 Compare May 6, 2026 19:36
@airspeedswift

Copy link
Copy Markdown
Member Author

@swift-ci please smoke test

… PackConformance::getAssociatedConformance

When a pattern conformance in the pack is invalid (e.g. its underlying conformance failed because of a prior diagnostic), `getAssociatedConformance` returned an invalid `ProtocolConformanceRef` whose `getType()` is null. The null type was pushed into `packElements` and tripped an assertion in `PackType::get`. Substitute `ErrorType` for the null so substitution can complete and the existing diagnostics surface to the user. Fixes swiftlang#88434.
@airspeedswift airspeedswift force-pushed the packconformance-getassociatedconformance-invalid-pattern branch from 5f5e499 to 9cd64d1 Compare May 6, 2026 21:37
@airspeedswift

Copy link
Copy Markdown
Member Author

@swift-ci please smoke test

@airspeedswift

Copy link
Copy Markdown
Member Author

We should probably fix the representation of invalid conformances to store a type at some point (today the invalid conformance is a singleton, literally a null pointer), since this sort of workaround has come up in several places already.

Filed #88902

@airspeedswift airspeedswift merged commit 8cb5dfc into swiftlang:main May 7, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants