Open
Description
The compiler issues error constant definition loop
for the following program:
package main
import "fmt"
const C = len(u)
func f() ([1]int, [C]float64) {
return [...]int{1}, [...]float64{1.1}
}
var u, v = f()
func main() {
fmt.Println(C, v)
}
In fact the value if C
(resp. the type of u
) does not depend on the type of the second return of f
.
The same program is compiled successfully by gccgo.
PS. Another test case
package main
import "fmt"
const C = len(u)
type S struct {
X [1]int
Y [C]int
}
var s S
var u, v = s.X, s.Y
func main() {
fmt.Println(C, v)
}