Skip to content

Commit 9524e93

Browse files
committed
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 <[email protected]> Run-TryBot: Robert Findley <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Robert Griesemer <[email protected]>
1 parent a11a171 commit 9524e93

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/go/types/infer.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ func (check *Checker) inferB(tparams []*TypeName, targs []Type, report bool) (ty
398398
if sbound != nil {
399399
if !u.unify(typ, sbound) {
400400
if report {
401-
check.errorf(tpar, 0, "%s does not match %s", tpar, sbound)
401+
check.errorf(tpar, _Todo, "%s does not match %s", tpar, sbound)
402402
}
403403
return nil, 0
404404
}
@@ -412,7 +412,7 @@ func (check *Checker) inferB(tparams []*TypeName, targs []Type, report bool) (ty
412412
// was given, unification produced the type list [int, []C, *A]. We eliminate the
413413
// remaining type parameters by substituting the type parameters in this type list
414414
// until nothing changes anymore.
415-
types, index = u.x.types()
415+
types, _ = u.x.types()
416416
if debug {
417417
for i, targ := range targs {
418418
assert(targ == nil || types[i] == targ)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2021 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package issue45985
6+
7+
// TODO(rFindley): this error should be on app[int] below.
8+
func app[S /* ERROR "type S = S does not match" */ interface{ type []T }, T any](s S, e T) S {
9+
return append(s, e)
10+
}
11+
12+
func _() {
13+
_ = app[int]
14+
}

0 commit comments

Comments
 (0)