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
[SR-13240] non-specific diagnostic when calling a function with two wrong-type arguments #55681
Comments
This problem seems to be related to this early return on CSSimplify Line 3657 in 71f6797
|
This also leads to ambiguous diagnostics in situations like infix operator ---
func --- (_ lhs: String, _ rhs: String) -> Bool {
return true
}
let x = 1
x --- x // type of expression is ambiguous without more context It is basically the same case |
IIRC you get a diagnostic if you have two different variables (x and y) so it seems like this only happens when you have >1 failure associated with the same argument? |
Do you mean like func twoargs(_ x: String, _ y: String) {}
func test() {
let x = 1
let y = 1
twoargs(x, y) // type of expression is ambiguous without more context
}
infix operator ---
func --- (_ lhs: String, _ rhs: String) -> Bool {
return true
}
let x = 1
let y = 1
x --- y // type of expression is ambiguous without more context In this case, we still get ambiguous for the same reason, the problem is when having more than one argument failure (for any argument) e.g. in those cases args #0 and #1 fail on the same call anchor. I really don't know what would be an approach to solve this, as the comment in line 3644 states ("we can consider overload unrelated"), but this leads to problems like those examples here if all overloads are ignored ... and change this would impact a lot of other diagnostics. |
Oh sorry, I think I got confused when I was testing out a few other cases. I thought I remembered seeing a diagnostic when using different variables instead of the same one. |
I think it might work to start recording all of the argument failures and increase a score significantly after each one to indicate that the more argument are mismatching the least desirable this overload choice is... |
@LucianoPAlmeida I'm taking about this bit Lines 3643 to 3657 in 506aa1d
Line 9812 in 506aa1d
|
Right @xedin let's try that! |
Fixed on master @marcrasi can you please test on the next available snapshot? thanks |
I verified it. Thanks!! |
Environment
swift-DEVELOPMENT-SNAPSHOT-2020-07-14-a-ubuntu20.04
Additional Detail from JIRA
md5: d23f6c9602953bf690f36dffaa470bb3
Issue Description:
The text was updated successfully, but these errors were encountered: