traefik / yaegi

Yaegi is Another Elegant Go Interpreter
https://pkg.go.dev/github.com/traefik/yaegi
Apache License 2.0
7.02k stars 348 forks source link

calling Symbols("") on new interpreter with stdlib.Symbols crashes with panic: reflect: call of MakeFunc with non-Func type #1629

Open rcoreilly opened 5 months ago

rcoreilly commented 5 months ago

The following program sample.go triggers an unexpected result

package main

import (
        "fmt"

        "github.com/traefik/yaegi/interp"
        "github.com/traefik/yaegi/stdlib"
)

func main() {
        i := interp.New(interp.Options{})
        i.Use(stdlib.Symbols) // commenting out this line prevents crash
        syms := i.Symbols("")
        fmt.Println(syms)
}

Expected result

$ go run ./sample.go

// lots of symbols here

Got

$ go run ./sample.go 
panic: reflect: call of MakeFunc with non-Func type

goroutine 1 [running]:
reflect.MakeFunc({0x100dfb588, 0x100cfe680}, 0x140003cbe40)
    /opt/homebrew/Cellar/go/1.22.1/libexec/src/reflect/makefunc.go:48 +0x17c
github.com/traefik/yaegi/interp.genFunctionWrapper.func1(0x140000e0420)
    /Users/oreilly/go/pkg/mod/github.com/traefik/yaegi@v0.16.1/interp/run.go:991 +0xe8
github.com/traefik/yaegi/interp.(*Interpreter).Symbols(0x14000034d88, {0x0, 0x0})
    /Users/oreilly/go/pkg/mod/github.com/traefik/yaegi@v0.16.1/interp/use.go:38 +0x408
main.main()
    /Users/oreilly/tmp/test/sample.go:13 +0x58
exit status 2

Yaegi Version

v0.16.1

Additional Notes

$ go version go version go1.22.1 darwin/arm64

macbook