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
Assignees
Milestone

Comments

@griesemer
Copy link
Contributor

@griesemer griesemer commented Oct 19, 2017

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 added this to the Go1.10 milestone Oct 19, 2017
@griesemer griesemer removed this from the Go1.10 milestone Oct 20, 2017
@griesemer griesemer added this to the Go1.11 milestone Oct 20, 2017
@griesemer
Copy link
Contributor Author

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

Loading

@gopherbot
Copy link

@gopherbot gopherbot commented Dec 13, 2017

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

Loading

@gopherbot gopherbot closed this in 973393c Feb 12, 2018
@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
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants