Skip to content

cmd/compile: invalidly inferred type for interface that doesn't use type parameter #60377

@griesemer

Description

@griesemer

In the following code:

type T[P any] interface {
	m()
}

func g[P any](T[P]) {}

func _() {
	var x T[int]
	g(x)         // here we infer P == int, but in fact any type of P would be ok
	g[string](x) // here we set P == string
}

we infer the type int for P of g. But in fact any type would make this code work. Type inference should not succeed in this case.

Metadata

Metadata

Assignees

Labels

FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions