Open zoola969 opened 10 months ago
Confirm that it still happens on master
.
I actually hit something very similar recently, but with a regular iota and typed constants:
type Enum int
const (
A = Enum(iota)
B
C
)
This produced A=0, B=2, C=4
for unknown reason, breaking the code that assumed it's sequential.
I will try to make a similar small reproducer. For now I was unable to, so it might be caused by something other code in the package. Probably something interferes with these const definitions.
@mvertes Could you please tag the issue? Looks important. I will try to fix it.
Actually, here's a small reproducer for my case:
package main
const (
A = Enum(iota)
B
C
)
type Enum int
func main() {
println(A, B, C)
}
This should produce 0 1 2
, but produces 0 2 4
instead. Moving type Enum int
before const
fixes the problem.
Sorry for the noise, my issue appears to be different. Opened #1596.
The following program
sample.go
triggers an unexpected resultExpected result
Got
Yaegi Version
v0.15.1
Additional Notes
No response