mirror of
https://github.com/golang/go
synced 2024-11-12 06:30:21 -07:00
go/types: adjust printing of type parameter in error
This is a clean port of CL 360514 to go/types. Change-Id: Ia13638b3758b3b8017867934d09136ac5f9a62ca Reviewed-on: https://go-review.googlesource.com/c/go/+/360935 Trust: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
parent
32d27527a6
commit
d6f7203a3c
@ -373,7 +373,6 @@ func (check *Checker) inferB(tparams []*TypeParam, targs []Type) (types []Type,
|
|||||||
|
|
||||||
// If a constraint has a structural type, unify the corresponding type parameter with it.
|
// If a constraint has a structural type, unify the corresponding type parameter with it.
|
||||||
for _, tpar := range tparams {
|
for _, tpar := range tparams {
|
||||||
typ := tpar
|
|
||||||
sbound := structure(tpar)
|
sbound := structure(tpar)
|
||||||
if sbound != nil {
|
if sbound != nil {
|
||||||
// If the structural type is the underlying type of a single
|
// If the structural type is the underlying type of a single
|
||||||
@ -381,8 +380,10 @@ func (check *Checker) inferB(tparams []*TypeParam, targs []Type) (types []Type,
|
|||||||
if named, _ := tpar.singleType().(*Named); named != nil {
|
if named, _ := tpar.singleType().(*Named); named != nil {
|
||||||
sbound = named
|
sbound = named
|
||||||
}
|
}
|
||||||
if !u.unify(typ, sbound) {
|
if !u.unify(tpar, sbound) {
|
||||||
check.errorf(tpar.obj, _Todo, "%s does not match %s", tpar.obj, sbound)
|
// TODO(gri) improve error message by providing the type arguments
|
||||||
|
// which we know already
|
||||||
|
check.errorf(tpar.obj, _Todo, "%s does not match %s", tpar, sbound)
|
||||||
return nil, 0
|
return nil, 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
package issue45985
|
package issue45985
|
||||||
|
|
||||||
// TODO(rFindley): this error should be on app[int] below.
|
// TODO(rFindley): this error should be on app[int] below.
|
||||||
func app[S /* ERROR "type S S does not match" */ interface{ ~[]T }, T any](s S, e T) S {
|
func app[S /* ERROR "S does not match" */ interface{ ~[]T }, T any](s S, e T) S {
|
||||||
return append(s, e)
|
return append(s, e)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user