Open muazhari opened 1 month ago
sample.go
package main import ( "fmt" "github.com/traefik/yaegi/interp" "math" ) func main() { c0Str := ` func c0(args ...any) (result any) { fmt.Println("c0") n := args[0].(int64) count := int64(0) for i := int64(1); i < n; i++ { for j := int64(1); j < (i * i); j++ { count += 1 } } return count } ` c1Str := ` func c1(args ...any) (result any) { fmt.Println("c1") count := int64(0) for i := int64(1); i < int64(math.Log2(float64(n))); i++ { for j := int64(1); j < n-i; j++ { count += 1 } } return count } ` i := interp.New(interp.Options{}) _, _ = i.Eval(` import ( "fmt" "math" ) `) _, _ = i.Eval(c0Str) _, _ = i.Eval(c1Str) c0v, _ := i.Eval("c0") c1v, _ := i.Eval("c1") c0I := c0v.Interface().(func(...any) any) c1I := c1v.Interface().(func(...any) any) c0F := c0I(int64(100)) c1F := c1I(int64(100)) fmt.Println(c0F) fmt.Println(c1F) }
some integer some integer
panic: runtime error: slice bounds out of range [1:0] goroutine 1 [running]: github.com/traefik/yaegi/interp.genFunctionWrapper.func1.1({0xc000012420, 0x1, 0x1?}) /home/muazhari/go/pkg/mod/github.com/traefik/yaegi@v0.16.1/interp/run.go:1000 +0x7f4 main.main() /mnt/c/Data/Apps/golang/main.go:266 +0x2c3 exit status 2
v0.16.1
No response
The following program
sample.go
triggers an unexpected resultExpected result
Got
Yaegi Version
v0.16.1
Additional Notes
No response