Skip to content

go/types, types2: type inference fails to infer type argument even though correct type is present in argument list #62335

Closed
@griesemer

Description

@griesemer
package main

type A struct{}
type B struct{}

var a A
var b B
var c struct{}

func main() {
	f(a, b, c) // ERROR "type B of b does not match inferred type A for P"
	f[struct{}](a, b, c)
}

func f[P any](...P) {}

fails to infer the type argument struct{} even though it appears in the function argument list (playground).

This bug existed since Go 1.18.
It partly interferes with a fix for #62157 (we can't fully fix #62157 without addressing this issue as well).

cc: @findleyr

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions