You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cmd/compile: iota inside function in a ConstSpec is not accepted #22344
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.
@go101 This "paradox" was addressed with the most recent changes for #15550. The value of iota is the index of the respective ConstSpec in the constant declaration. Here you have a constant declaration inside the function, and the iota is in the first ConstSpec of that constant declaration, which has index 0. Hence the value of iota and thus a is 0.
Activity
griesemer commentedon Oct 19, 2017
Not urgent in any way but marked as 1.10 so it doesn't slip from the radar. Might be an easy fix.
zigo101 commentedon Oct 20, 2017
There is a paradox
The current gc thinks
ais0.mdempsky commentedon Oct 20, 2017
const a = iotasets a to 0.griesemer commentedon Oct 20, 2017
@go101 This "paradox" was addressed with the most recent changes for #15550. The value of
iotais the index of the respective ConstSpec in the constant declaration. Here you have a constant declaration inside the function, and theiotais in the first ConstSpec of that constant declaration, which has index 0. Hence the value ofiotaand thusais 0.gopherbot commentedon Sep 11, 2019
Change https://golang.org/cl/194717 mentions this issue:
cmd/compile: allow iota inside function in a ConstSpec