mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
go/types: add a test case for issue 45985
The fix for #45985 is a little subtle. Start by committing the (bad) test case. For #45985 Change-Id: Ia6625818e9b1c5e869b2c2f724f817c13c9944d1 Reviewed-on: https://go-review.googlesource.com/c/go/+/317471 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
a11a1711b0
commit
9524e93adf
2 changed files with 16 additions and 2 deletions
|
|
@ -398,7 +398,7 @@ func (check *Checker) inferB(tparams []*TypeName, targs []Type, report bool) (ty
|
||||||
if sbound != nil {
|
if sbound != nil {
|
||||||
if !u.unify(typ, sbound) {
|
if !u.unify(typ, sbound) {
|
||||||
if report {
|
if report {
|
||||||
check.errorf(tpar, 0, "%s does not match %s", tpar, sbound)
|
check.errorf(tpar, _Todo, "%s does not match %s", tpar, sbound)
|
||||||
}
|
}
|
||||||
return nil, 0
|
return nil, 0
|
||||||
}
|
}
|
||||||
|
|
@ -412,7 +412,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
|
// 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
|
// remaining type parameters by substituting the type parameters in this type list
|
||||||
// until nothing changes anymore.
|
// until nothing changes anymore.
|
||||||
types, index = u.x.types()
|
types, _ = u.x.types()
|
||||||
if debug {
|
if debug {
|
||||||
for i, targ := range targs {
|
for i, targ := range targs {
|
||||||
assert(targ == nil || types[i] == targ)
|
assert(targ == nil || types[i] == targ)
|
||||||
|
|
|
||||||
14
src/go/types/testdata/fixedbugs/issue45985.go2
vendored
Normal file
14
src/go/types/testdata/fixedbugs/issue45985.go2
vendored
Normal file
|
|
@ -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(rFindley): 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]
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue