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: len() on an array type-parameter not recognized as compile-time constant when type list has multiple entries #42029

AndrewWPhillips opened this issue Oct 16, 2020 · 1 comment


Copy link

@AndrewWPhillips AndrewWPhillips commented Oct 16, 2020

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

$ go version
go version devel +e9e897e0fe Tue Sep 15 19:46:15 2020 +0000 windows/amd64

Also go2go playground (see link below)

Does this issue reproduce with the latest release?


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

go env Output
$ go env

What did you do?

func f[T interface { type [2]int, [3]int } ]() {
  var dummy T
  var a [len(dummy)]bool

func main() {


What did you expect to see?


What did you see instead?

type checking failed for main
prog.go2:11:9: array length len(dummy) (value of type int) must be constant

Copy link

@AndrewWPhillips AndrewWPhillips commented Oct 17, 2020

I tried to produce a simpler example but this works:

type a[T interface { type [2]int, [3]int }] T

func main() {
	var dummy a[[3]int]
	const c = len(dummy)

I'm not sure what the difference but this allowed a workaround.

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

Successfully merging a pull request may close this issue.

None yet
3 participants