Skip to content

[Diagnostics] Remove FailureDiagnosis::diagnoseParameterErrors from CSDiag #29734

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 4 commits into from
Feb 11, 2020

Conversation

LucianoPAlmeida
Copy link
Contributor

This removes some obsolete code involving argument-to-param from repairFailures.
Removing FailureDiagnosis::diagnoseParameterErrors from CSDiag and fixing the remaining edge cases that were still being diagnosed by that. All of them related to ambiguity and generic types.
e.g.

func f<T>(_ i: T, _ j: T) {}
let _ = f(Int(3), Float(2.5)) 

cc @xedin @hborla

@xedin
Copy link
Contributor

xedin commented Feb 10, 2020

@LucianoPAlmeida I'll try to take a look tonight, thank you!

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.

Overall I think this is a way to go but since @hborla is working on changed to diagnoseAmbiguityWithFixes she should take a look as well.

@@ -2765,6 +2765,9 @@ bool ConstraintSystem::diagnoseAmbiguityWithFixes(
ParameterList,
/// General ambiguity failure.
General,
/// Argument mismatch ambiguity where each solution has the same
/// argument mismatch fixes for the same call.
ArgumentMismatch
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe that could be generalized to all fixes. That is exactly something @hborla is about to open a PR for, it would cover not only argument mismatches but any ambiguity which involves the same fix kind at a shared location :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean the same callee location? because in those cases all the fixes are the same, but each one for an argument. e.g. In the case of

func f<T>(_: T, _: T) {}
f(Int(1), Float(1))

There is a fix located at arg #1 in the first solution which was attempted (Int, Int)->Void and another at #0

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, the two fixes here have different locators so it's not quite the same case as N common fixes across N solutions

Copy link
Member

Choose a reason for hiding this comment

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

Actually, maybe the locator doesn't matter. With my changes here, I've implemented a special method on CSFix for diagnosing for ambiguity when the fix is "common" across all solutions, but I consider a fix "common" only when the locator is the same. Instead of assuming that the locator must be the same, we can let the particular fix kind decide what it means to be "common"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Humm ... so in for these case for AllowTupleTypeMismatch and AllowArgumentMismatch fixes will be special cases where we could ignore locator for common to be able to disambiguate.

@LucianoPAlmeida LucianoPAlmeida force-pushed the remove-diag-parameters-errors branch from 0b7d316 to 70a284c Compare February 10, 2020 10:47
@LucianoPAlmeida LucianoPAlmeida force-pushed the remove-diag-parameters-errors branch from 70a284c to 46092af Compare February 10, 2020 10:48
@LucianoPAlmeida
Copy link
Contributor Author

Overall I think this is a way to go but since @hborla is working on changed to diagnoseAmbiguityWithFixes she should take a look as well.

Oh right, Thank you for taking a look @xedin :)

@hborla
Copy link
Member

hborla commented Feb 10, 2020

Thank you for porting this @LucianoPAlmeida ! We are so close to removing CSDiag completely, and we really appreciate you continuing to help out!

As Pavel mentioned, I'm rewriting diagnoseAmbiguityWithFixes here to involve fewer special cases, and the strategy has changed to be based on the differences between solutions. It's currently looking at differences in overload choices, but we can cover a case like

func f<T>(_ i: T, _ j: T) {}
let _ = f(Int(3), Float(2.5)) 

by looking at the type variable binding for generic parameter T across all solutions and report could not infer generic parameter 'T' if there is a difference. However, I think we can take your change as-is and I'll take care of covering this case with my new changes.

@xedin
Copy link
Contributor

xedin commented Feb 11, 2020

@swift-ci please smoke test

@xedin xedin merged commit b3590c5 into swiftlang:master Feb 11, 2020
@LucianoPAlmeida LucianoPAlmeida deleted the remove-diag-parameters-errors branch March 4, 2020 13:36
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.

3 participants