Skip to content

Interface with unexported method fails type assertion #1355

@theclapp

Description

@theclapp

The following program sample.go triggers an unexpected result

package main

import (
	"fmt"

	"github.com/traefik/yaegi/_test/p2"
)

func main() {
	var v *p2.T
	var i interface{}

	i = v
	if _, ok := i.(p2.I); ok {
		fmt.Printf("ok\n")
	} else {
		fmt.Printf("not ok\n")
	}
}

Expected result

$ go run ./sample.go
ok

Got

$ yaegi run ./sample.go
not ok

Yaegi Version

14acf61

Additional Notes

github.com/traefik/yaegi/_test/p2/p2.go is

package p2

type I interface {
	isI()
}

type T struct{}

func (t *T) isI() {}

This is similar to #1025.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions