Skip to content

Weird behaviour with reflect #1693

@pjebs

Description

@pjebs

The following program sample.go triggers an unexpected result

func main() {

	i := interp.New(interp.Options{})
	i.Use(stdlib.Symbols)

	i.Eval(`package main`)
	i.Eval(`import "fmt"`)
	i.Eval(`import "reflect"`)
	i.Eval(`type Printer interface{ Print(s string) }`)
	i.Eval(`var zzzz Printer`)

	i.Eval(`var a = zzzz`)
	i.Eval(`fmt.Println(reflect.TypeOf(&a).Elem().PkgPath())`)
	i.Eval(`fmt.Println(reflect.TypeOf(&a).Elem().Name())`)
	i.Eval(`fmt.Printf("%#v %T", a, a)`)
}

Expected result

main
Printer
<nil> <nil>

See: https://go.dev/play/p/ZMtlEXwpEjf

Got

github.com/traefik/yaegi/interp
valueInterface
<nil> <nil>

Yaegi Version

v0.16.1

Additional Notes

See: https://go.dev/play/p/ZMtlEXwpEjf

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions