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
The following program sample.go triggers an unexpected result
package main
import (
"fmt""github.com/traefik/yaegi/interp""math"
)
funcmain() {
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)
}
Expected result
some integersome integer
Got
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 +0x7f4main.main() /mnt/c/Data/Apps/golang/main.go:266 +0x2c3exit status 2
Yaegi Version
v0.16.1
Additional Notes
No response
The text was updated successfully, but these errors were encountered:
The following program
sample.go
triggers an unexpected resultExpected result
Got
Yaegi Version
v0.16.1
Additional Notes
No response
The text was updated successfully, but these errors were encountered: