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-10852] [Opaque Result Types] Generic parameter 'τ_0_0' could not be inferred #53242
Comments
cc @jckarter |
I wonder if it's getting confused doing overload resolution on `==` and misattributing the type error. |
Comment by Tapan Thaker (JIRA) Taking this bug. |
Comment by Tapan Thaker (JIRA)
func ==<T: EquatableBox, U: EquatableBox>(lhs: T, rhs: U) -> Bool {
return lhs.value == rhs.value
}
|
Comment by Tapan Thaker (JIRA) @jckarter: To me, it looks like ConstraintSolver solved and inferred the correct types. Also, I get that the compiler could not find a ---Solution---
Fixed score: 2 0 0 0 0 0 0 0 0 0 0 0
Type variables:
$T66 as some EquatableBox @ locator@0x7fa5430a3078 [OverloadedDeclRef@Hello.swift:26:11 -> generic parameter 'U']
$T2 as some EquatableBox @ locator@0x7fa54389d7a0 [DeclRef@Hello.swift:26:14]
$T1 as some EquatableBox @ locator@0x7fa54389d718 [DeclRef@Hello.swift:26:9]
$T3 as Bool @ locator@0x7fa54389d830 [Binary@Hello.swift:26:11 -> function result]
$T0 as (some EquatableBox, some EquatableBox) -> Bool @ locator@0x7fa54389a600 [OverloadedDeclRef@Hello.swift:26:11]
$T65 as some EquatableBox @ locator@0x7fa5430a3030 [OverloadedDeclRef@Hello.swift:26:11 -> generic parameter 'T']
Overload choices:
locator@0x7fa54389d7a0 [DeclRef@Hello.swift:26:14] with Hello.(file).b@Hello.swift:24:5 as b: some EquatableBox
locator@0x7fa54389d718 [DeclRef@Hello.swift:26:9] with Hello.(file).a@Hello.swift:23:5 as a: some EquatableBox
locator@0x7fa54389a600 [OverloadedDeclRef@Hello.swift:26:11] with Hello.(file).==@Hello.swift:6:6 as ==: ($T65, $T66) -> Bool
Constraint restrictions:
Disjunction choices:
Opened types:
locator@0x7fa54389a600 [OverloadedDeclRef@Hello.swift:26:11] opens τ_0_0 -> $T65, τ_0_1 -> $T66
Fixes:
[fix: skip same-type generic requirement] @ locator@0x7fa5430a3228 [OverloadedDeclRef@Hello.swift:26:11 -> opened generic -> type parameter requirement #​2 (same-type)]
[fix: skip same-type generic requirement] @ locator@0x7fa5430a32d8 [OverloadedDeclRef@Hello.swift:26:11 -> opened generic -> type parameter requirement #​3 (same-type)]
---Constraint solving for the expression at [Hello.swift:26:9 - line:26:9]---
(overload set choice binding $T0 := some EquatableBox)
---Initial constraints for the given expression---
(declref_expr type='some EquatableBox' location=Hello.swift:26:9 range=[Hello.swift:26:9 - line:26:9] decl=Hello.(file).a@Hello.swift:23:5 function_ref=unapplied)
Score: 0 0 0 0 0 0 0 0 0 0 0 0
Type Variables:
$T0 [lvalue allowed] [noescape allowed] as some EquatableBox @ locator@0x7fa542960600 [DeclRef@Hello.swift:26:9]
Active Constraints:
Inactive Constraints:
Resolved overloads:
selected overload set choice a: $T0 == some EquatableBox
(found solution 0 0 0 0 0 0 0 0 0 0 0 0)
---Solver statistics---
Total number of scopes explored: 1
Maximum depth reached while exploring solutions: 1
Time: 1.239170e+02ms |
Thanks for looking into this! @xedin where would be a good place to improve the diagnostic here? The issue is that the constraints on |
tt (JIRA User) Looks like we already record fixes for unsatisfied requirements and form a solution so the only remaining problem to figure out is why don't we emit the diagnostics for recorded fixes.
|
Looks like we produce a much better error now on master:
WDYT, @theblixguy? |
Follow up on this.
|
@Chevel Yours appears to be a different bug, please open a new issue. This particular one was fixed. |
Environment
Xcode 11 Beta 1, Swift 5.1, macOS 10.15 Developer Beta 1 (19A471t)
Additional Detail from JIRA
md5: f781c969fc89c0f73616e7ae7b35dbfa
Issue Description:
I don't think "τ_{depth}_{index}" is supposed to leak into diagnostics:
The text was updated successfully, but these errors were encountered: