traefik / yaegi

Yaegi is Another Elegant Go Interpreter
https://pkg.go.dev/github.com/traefik/yaegi
Apache License 2.0
7.02k stars 349 forks source link

out of order global declaration #1536

Closed mvertes closed 1 year ago

mvertes commented 1 year ago

The following program sample.go triggers an unexpected result

package main

var a [len(prefix+path) + 2]int

const (
    prefix = "/usr/"
    path   = prefix + "local/bin"
)

func main() {
    println(len(a))
}

Expected result

$ go run ./sample.go
21

Got

$ yaegi ./sample.go
run: ./sample.go:3:5: constant definition loop
exit status 1

Yaegi Version

v0.15.1

Additional Notes

It does not fail if the variable is defined after the constants.