Skip to content

Commit f5423ea

Browse files
committed
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 <[email protected]> Reviewed-by: Robert Findley <[email protected]>
1 parent 832c70e commit f5423ea

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/cmd/compile/internal/types2/infer.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ func (check *Checker) inferB(tparams []*TypeName, targs []Type, report bool) (ty
417417
// was given, unification produced the type list [int, []C, *A]. We eliminate the
418418
// remaining type parameters by substituting the type parameters in this type list
419419
// until nothing changes anymore.
420-
types, index = u.x.types()
420+
types, _ = u.x.types()
421421
if debug {
422422
for i, targ := range targs {
423423
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(gri): 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)