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

cmd/go2go: Type aliases of generic types fail to compile #39768

Closed
firelizzard18 opened this issue Jun 23, 2020 · 3 comments
Closed

cmd/go2go: Type aliases of generic types fail to compile #39768

firelizzard18 opened this issue Jun 23, 2020 · 3 comments
Assignees
Labels
Milestone

Comments

@firelizzard18
Copy link

@firelizzard18 firelizzard18 commented Jun 23, 2020

The design draft (Appendix > Generic type aliases) indicates that the following would work:

package pkg

type Vector(type T) []T
type VectorAlias = Vector
var v Vector(int)

However, it doesn't: https://go2goplay.golang.org/p/Gnfiupx2_xT

type checking failed for main
prog.go2:4:20: cannot use generic type Vector(type T) without instantiation

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

go2goplay.golang.org and go version devel +da7932368b Mon Jun 22 19:06:44 2020 +0000 linux/amd64

@griesemer
Copy link
Contributor

@griesemer griesemer commented Jun 23, 2020

At the moment only this works.

This is a current limitation of the prototype.

@griesemer griesemer self-assigned this Jun 23, 2020
@griesemer griesemer added the NeedsFix label Jun 23, 2020
@griesemer griesemer added this to the Unreleased milestone Jun 23, 2020
@gopherbot
Copy link

@gopherbot gopherbot commented Jun 23, 2020

Change https://golang.org/cl/239387 mentions this issue: [dev.go2go] go/types: permit alias to generic type

@griesemer
Copy link
Contributor

@griesemer griesemer commented Jun 23, 2020

Turns out this was trivial to fix. Now implemented on dev.go2go. In the playground when it gets updated.

@firelizzard18 Thanks for bringing this to my attention.

@griesemer griesemer closed this Jun 23, 2020
gopherbot pushed a commit that referenced this issue Jun 23, 2020
Fixes #39768.

Change-Id: I68c8fbec5adc50e448dabe90b212ef147a384a06
Reviewed-on: https://go-review.googlesource.com/c/go/+/239387
Reviewed-by: Robert Griesemer <gri@golang.org>
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
3 participants
You can’t perform that action at this time.