traefik / yaegi

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

bug: undefined selector github.com/traefik/yaegi/stdlib/ syscall.Signal #951

Open benjaminjkraft opened 3 years ago

benjaminjkraft commented 3 years ago

This prevents importing x/sys/unix (thus any package which uses it -- for me relevantly logrus).

$ rlwrap yaegi -i -unsafe -syscall -unrestricted
> import "golang.org/x/sys/unix"
1:21: import "golang.org/x/sys/unix" error: /home/benkraft/.go/src/golang.org/x/sys/unix/syscall_linux.go:347:30: undefined selector github.com/traefik/yaegi/stdlib/
syscall.Signal
mewmew commented 1 year ago

I tried on the latest revision of Yaegi (da27c4fbc25f1023295585b8c818e3b34e6149b9) and the import of golang.org/x/sys/unix is still failing.

The error message has changed though. Now Yaegi fails with error "incomplete type ifreq".

Steps to reproduce

$ export GOPATH=/tmp/bar
$ env GO111MODULE=off go get golang.org/x/sys/unix
$ yaegi -i -unsafe -syscall -unrestricted
> import "golang.org/x/sys/unix"
/tmp/bar/src/golang.org/x/sys/unix/ifreq_linux.go:132:9: CFG post-order panic: /tmp/bar/src/golang.org/x/sys/unix/ifreq_linux.go:26:24: incomplete type ifreq
goroutine 34 [running]:
runtime/debug.Stack()
    /usr/lib/go/src/runtime/debug/stack.go:24 +0x65
github.com/traefik/yaegi/interp.(*Interpreter).EvalWithContext.func1.1()
    /home/u/Desktop/yaegi_new/interp/interp.go:588 +0x99
panic({0xeae3c0, 0xc000013f80})

The ifreq type is present however in golang.org/x/sys/unix/ztypes_linux_amd64.go (extract below):

//go:build amd64 && linux
// +build amd64,linux

package unix

type ifreq struct {
    Ifrn [16]byte
    Ifru [24]byte
}