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

cmd/go2go: cannot infer T in an embedded field. #40814

Open
YoshikiShibata opened this issue Aug 15, 2020 · 1 comment
Open

cmd/go2go: cannot infer T in an embedded field. #40814

YoshikiShibata opened this issue Aug 15, 2020 · 1 comment
Assignees
Milestone

Comments

@YoshikiShibata
Copy link

@YoshikiShibata YoshikiShibata commented Aug 15, 2020

Program https://go2goplay.golang.org/p/L5jQWGZvxDe cannot be compiled:

package main

import "fmt"

type X[type T] struct {
}

func (x X[T]) Hello() (T, bool) {
	var v T
	return v, true
}

type Y[type T] struct {
	X[T]
}

func (y Y[T]) Foo() {

	s, ok := y.Hello()
	if ok {
		fmt.Println(s)
	}

}

func main() {
	y := Y[string]{}
	y.Foo()
}
type checking failed for main
prog.go2:19:11: type Y(T) of y does not match X(T) (cannot infer T)
@griesemer
Copy link
Contributor

@griesemer griesemer commented Aug 28, 2020

This is a variation of the same problem that plagues #39758. It's not yet implemented and thus leads to odd errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.