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""github.com/traefik/yaegi/stdlib"
)
varfuncs=`package mainimport "fmt"func AppendSlice() { type funcType func() var fs []funcType fs = append(fs, a) for _, f := range fs { f() }}func a(){ fmt.Println("execute func a")}`funcmain(){
engine:=interp.New(interp.Options{})
// 引入标准库iferr:=engine.Use(stdlib.Symbols); err!=nil {
panic(err)
}
_, err:=engine.Eval(funcs)
iferr!=nil {
fmt.Printf("evel funcs failed:%v \n", err)
return
}
v, err:=engine.Eval("main.AppendSlice")
iferr!=nil {
fmt.Printf("evel main.AppendSlice failed:%v \n", err)
return
}
f, ok:=v.Interface().(func())
if!ok {
fmt.Println("func not type of metadataudf.UserDefineFunc ")
return
}
f()
}
Expected result
go run main.go
Got
7:2: panicpanic: reflect.Set: value of type *interp.node is not assignable to type func() [recovered] panic: reflect.Set: value of type *interp.node is not assignable to type func()
Yaegi Version
v0.15.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
go run main.go
Got
Yaegi Version
v0.15.1
Additional Notes
No response
The text was updated successfully, but these errors were encountered: