]> Cypherpunks repositories - gostls13.git/commitdiff
go/types: adjust printing of type parameter in error
authorRobert Findley <rfindley@google.com>
Tue, 2 Nov 2021 22:29:27 +0000 (18:29 -0400)
committerRobert Findley <rfindley@google.com>
Wed, 3 Nov 2021 00:07:03 +0000 (00:07 +0000)
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>
src/go/types/infer.go
src/go/types/testdata/fixedbugs/issue45985.go2

index 61f7eaf91ea7a44b6ebbe0ad7996dc2137626ebf..41326a1be8bd3574ab632d63331418f7424f7416 100644 (file)
@@ -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.
        for _, tpar := range tparams {
-               typ := tpar
                sbound := structure(tpar)
                if sbound != nil {
                        // 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 {
                                sbound = named
                        }
-                       if !u.unify(typ, sbound) {
-                               check.errorf(tpar.obj, _Todo, "%s does not match %s", tpar.obj, sbound)
+                       if !u.unify(tpar, 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
                        }
                }
index 07395911cd17ee490722fdd2b8fb6af5b753f251..637e2cad5e05e0f42513b790c7f150329c934191 100644 (file)
@@ -5,7 +5,7 @@
 package issue45985
 
 // 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)
 }