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: iota inside function in a ConstSpec is not accepted #22345

Closed
griesemer opened this issue Oct 19, 2017 · 2 comments
Closed

go/types: iota inside function in a ConstSpec is not accepted #22345

griesemer opened this issue Oct 19, 2017 · 2 comments
Milestone

Comments

@griesemer
Copy link
Contributor

https://play.golang.org/p/K0Vga-Y1fv reports an error, but the spec doesn't prohibit this code.
https://play.golang.org/p/MbPQO9FJku is accepted, and there is no reason why the former, with iota being declared in the universe block shouldn't also be accepted within the constant declaration.

See also #22344 .

@griesemer griesemer self-assigned this Oct 19, 2017
@griesemer griesemer modified the milestones: Go1.10, Go1.11 Oct 19, 2017
@griesemer
Copy link
Contributor Author

griesemer commented Dec 13, 2017

Some more fun test cases:

const (
	_ = unsafe.Sizeof(iota)
	_ = unsafe.Sizeof(func() { _ = iota })
	_ = unsafe.Sizeof(func() { const _ = iota })
	_ = unsafe.Sizeof(func() { var _ = iota })
	_ = unsafe.Sizeof(func() { type _ [iota]byte })
	_ = unsafe.Sizeof(func() { func() int { return iota }() })
)

@gopherbot
Copy link

Change https://golang.org/cl/83579 mentions this issue: go/types: accept iotas inside closures of const init expressions

@golang golang locked and limited conversation to collaborators Feb 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants