traefik / yaegi

Yaegi is Another Elegant Go Interpreter

Home Page:https://pkg.go.dev/github.com/traefik/yaegi

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't append to struct's slice of functions

danielnovograd opened this issue · comments

The following program sample.go triggers an unexpected result

package main

import "fmt"

type funclistItem func()

type funclist struct {
	list []funclistItem
}

func main() {
	funcs := funclist{}

	funcs.list = append(funcs.list, func() { fmt.Println("first") })

	for _, f := range funcs.list {
		f()
	}
}

Expected result

$ go run ./sample.go
// first

Got

$ yaegi ./sample.go
// reflect.Set: value of type *interp.node is not assignable to type func()

Yaegi Version

0218249

Additional Notes

First noticed this when trying to append a list of custom function types, but also breaks with func literals.