Skip to content

Add some diagnostics related to lifetime dependence and function types #74956

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 3 commits into from
Jul 10, 2024

Conversation

meg-gupta
Copy link
Contributor

rdar://126169735

@meg-gupta
Copy link
Contributor Author

@swift-ci smoke test

Copy link
Contributor

@atrick atrick left a comment

Choose a reason for hiding this comment

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

Thanks! Looks good to me with Pavel's recommendations.

@meg-gupta meg-gupta force-pushed the lifetimedepfunctiontype branch from 0a4dd8c to 13cfbca Compare July 9, 2024 16:14
@meg-gupta
Copy link
Contributor Author

@swift-ci test

Copy link
Contributor

@atrick atrick left a comment

Choose a reason for hiding this comment

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

I suggest merging this now that you have fixed all of @xedin's suggestions since we need to make sure it lands while you are available to respond to problems.

@@ -3248,6 +3248,10 @@ ConstraintSystem::matchFunctionTypes(FunctionType *func1, FunctionType *func2,
if (!matchFunctionIsolations(func1, func2, kind, flags, locator))
return getTypeMatchFailure(locator);

if (func1->getLifetimeDependenceInfo() != func2->getLifetimeDependenceInfo()) {
return getTypeMatchFailure(locator);
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 this works because the solver would use a "catch all" conversion fix for arguments but maybe we should add a tailored fix for this to indicate what really mismatched here instead of making developers compare types visually and guess?

Copy link
Contributor Author

@meg-gupta meg-gupta Jul 10, 2024

Choose a reason for hiding this comment

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

Are you suggesting to use a ContextualFailure? I didn't see precedent in CSSimplify where a ContextualFailure was used without attempting a ConstraintFix. Most type mismatches without ConstraintFix were flagged with the generic getTypeMatchFailure .
If it is okay to use a ContextualFailure here, I can do that as a follow on PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't really want to implement a ConstraintFix here. It can cause cascaded SIL diagnostics later on and maybe even more confusing to the user.

@meg-gupta meg-gupta merged commit 4993f4b into swiftlang:main Jul 10, 2024
5 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
Development

Successfully merging this pull request may close these issues.

4 participants