Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

impossible type assertion #1651

Open
thorsager opened this issue Jul 18, 2024 · 0 comments
Open

impossible type assertion #1651

thorsager opened this issue Jul 18, 2024 · 0 comments
Labels
area/core bug Something isn't working

Comments

@thorsager
Copy link

The following program sample.go triggers an unexpected result

package main

type Mover interface {
	Move() error
}

type car struct {
	Mover
}

type engine struct {
}

func (e *engine) Move() error {
	println("engine moved")
	return nil
}

func newMover() Mover {
	return car{
		Mover: &engine{},
	}
}

func main() {
	mover := newMover()
	if _, ok := mover.(car); ok {
		println("mover is a car")
	}
	_ = mover.Move()
}

Expected result

mover is a car
engine moved

Got

run: ./sample.go:27:14: impossible type assertion: main.car does not implement main.Mover (missing Move method)

Yaegi Version

v0.16.1

Additional Notes

No response

@mvertes mvertes added bug Something isn't working area/core labels Jul 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/core bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants