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

Open
AndrewWPhillips opened this issue Oct 16, 2020 · 1 comment
Assignees
Milestone

Comments

@AndrewWPhillips
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?

yes

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
  println(len(a))
}

func main() {
  f[[3]int]()
}

OR

https://go2goplay.golang.org/p/BQFXljOS9zF

What did you expect to see?

3

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

@AndrewWPhillips
Copy link
Author

@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)
}

https://go2goplay.golang.org/p/bpK6OWMpRVN

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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants