Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go/types, types2: chan interface unifies with chan struct, resulting in misleading error message #60562

Closed
griesemer opened this issue Jun 1, 2023 · 3 comments
Assignees
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Milestone

Comments

@griesemer
Copy link
Contributor

package p

type S[T any] struct{}

func (S[T]) m(T) {}

func f[T any](chan S[T]) {}

func _() {
	var s chan interface{ m(int) }
	f(s)
}

produces

testdata/manual.go:11:4: cannot use s (variable of type chan interface{m(int)}) as chan S[int] value in argument to f

but it should say something like

testdata/manual.go:11:4: type chan interface{m(int)} of s does not match chan S[T] (cannot infer T)
@griesemer griesemer added the NeedsFix The path to resolution is known, but the work has not been done. label Jun 1, 2023
@griesemer griesemer added this to the Go1.21 milestone Jun 1, 2023
@griesemer griesemer self-assigned this Jun 1, 2023
@griesemer
Copy link
Contributor Author

cc @findleyr

@griesemer
Copy link
Contributor Author

Go 1.20 produces the correct error. Regression.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/499996 mentions this issue: go/types, types2: report inference instead of assignment failure when types can't match

@golang golang locked and limited conversation to collaborators Jun 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Projects
None yet
Development

No branches or pull requests

2 participants