The following program sample.go triggers an unexpected result
package main
import (
"fmt"
"github.com/traefik/yaegi/interp"
)
func call() string {
ch := make(chan string, 1)
ch <- "ok"
return <-ch
}
func main() {
fmt.Println(call()) // ok
j := interp.New(interp.Options{})
_, _ = j.Eval(`package main
func Call() string {
ch := make(chan string, 1)
ch <- "ok"
v:= <-ch
return v
}
`)
callAny, _ := j.Eval("main.Call")
s := callAny.Interface().(func() string)() // ok
fmt.Println(s)
i := interp.New(interp.Options{})
_, _ = i.Eval(`package main
func Call() string {
ch := make(chan string, 1)
ch <- "ok"
return <-ch
}
`)
callAny, _ = i.Eval("main.Call")
s = callAny.Interface().(func() string)() // panic: reflect: reflect.Value.Set using unaddressable value [recovered, repanicked]
fmt.Println(s)
}
Expected result
ok
ok
4:8: panic: main.Call(...)
panic: reflect: reflect.Value.Set using unaddressable value [recovered, repanicked]
Got
Yaegi Version
0.16.1
Additional Notes
return <-ch will be panic: reflect: reflect.Value.Set using unaddressable value [recovered, repanicked] ?
The following program
sample.gotriggers an unexpected resultExpected result
Got
-Yaegi Version
0.16.1
Additional Notes
return <-ch will be panic: reflect: reflect.Value.Set using unaddressable value [recovered, repanicked] ?