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

dev.typeparams: type checker does not allow to use receive operation even all types in type list are channels #43671

Open
tdakkota opened this issue Jan 13, 2021 · 2 comments
Assignees
Labels
Milestone

Comments

@tdakkota
Copy link

@tdakkota tdakkota commented Jan 13, 2021

What version of Go are you using (go version)?

$ go version
go version devel +f065ff221b Tue Jan 12 15:56:55 2021 -0800 windows/amd64

Does this issue reproduce with the latest release?

n/a

What operating system and processor architecture are you using (go env)?

  • windows/amd64
  • go2go playground

What did you do?

https://go2goplay.golang.org/p/4ERkDYXAVM-
Also, I got same result from dev.typeparams typechecker using

$ go tool compile -G ./example.go

The problem is here

case syntax.Recv:
typ := x.typ.Chan()
if typ == nil {
check.invalidOpf(x, "cannot receive from non-channel %s", x)
x.mode = invalid
return
}
if typ.dir == SendOnly {
check.invalidOpf(x, "cannot receive from send-only channel %s", x)
x.mode = invalid
return
}
x.mode = commaok
x.typ = typ.elem
check.hasCallOrRecv = true
return
}

x.typ.Chan() returns nil if x.typ is a *TypeParam.

What did you expect to see?

Successful type-check or a stub error like generic slice expressions not yet implemented. All types in RecvChan[T] type list support receive operation.

What did you see instead?

An error

invalid operation: cannot receive from non-channel ch (variable of type parameter type C)
@tdakkota
Copy link
Author

@tdakkota tdakkota commented Jan 13, 2021

@griesemer griesemer self-assigned this Jan 13, 2021
@griesemer griesemer added this to the Go1.17 milestone Jan 13, 2021
@griesemer griesemer added the NeedsFix label Jan 13, 2021
@griesemer
Copy link
Contributor

@griesemer griesemer commented Jan 13, 2021

This has not yet been implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.