From f5423ea615b94455e4f6b9cbee491b492bf2e1fe Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Thu, 6 May 2021 14:46:40 -0700 Subject: [PATCH] cmd/compile/internal/types2: add test case for issue 45985 This is a port of https://golang.org/cl/317471. Updates #45985. Change-Id: I539d0fa6f9a77eb2fc169a21c5db9921f8eceb03 Reviewed-on: https://go-review.googlesource.com/c/go/+/317732 Trust: Robert Griesemer Reviewed-by: Robert Findley --- src/cmd/compile/internal/types2/infer.go | 2 +- .../types2/testdata/fixedbugs/issue45985.go2 | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 src/cmd/compile/internal/types2/testdata/fixedbugs/issue45985.go2 diff --git a/src/cmd/compile/internal/types2/infer.go b/src/cmd/compile/internal/types2/infer.go index c136823fd8..f37d7f6477 100644 --- a/src/cmd/compile/internal/types2/infer.go +++ b/src/cmd/compile/internal/types2/infer.go @@ -417,7 +417,7 @@ func (check *Checker) inferB(tparams []*TypeName, targs []Type, report bool) (ty // was given, unification produced the type list [int, []C, *A]. We eliminate the // remaining type parameters by substituting the type parameters in this type list // until nothing changes anymore. - types, index = u.x.types() + types, _ = u.x.types() if debug { for i, targ := range targs { assert(targ == nil || types[i] == targ) diff --git a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue45985.go2 b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue45985.go2 new file mode 100644 index 0000000000..7678e348ef --- /dev/null +++ b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue45985.go2 @@ -0,0 +1,14 @@ +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package issue45985 + +// TODO(gri): this error should be on app[int] below. +func app[S /* ERROR "type S = S does not match" */ interface{ type []T }, T any](s S, e T) S { + return append(s, e) +} + +func _() { + _ = app[int] +} -- 2.50.0