github.com/go-asm/go@v1.21.1-0.20240213172139-40c5ead50c48/types/testdata/fixedbugs/issue48619.go (about)

     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 p
     6  
     7  func f[P any](a, _ P) {
     8  	var x int
     9  	// TODO(gri) these error messages, while correct, could be better
    10  	f(a, x /* ERROR "type int of x does not match inferred type P for P" */)
    11  	f(x, a /* ERROR "type P of a does not match inferred type int for P" */)
    12  }
    13  
    14  func g[P any](a, b P) {
    15  	g(a, b)
    16  	g(&a, &b)
    17  	g([]P{}, []P{})
    18  
    19  	// work-around: provide type argument explicitly
    20  	g[*P](&a, &b)
    21  	g[[]P]([]P{}, []P{})
    22  }