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: Looks like the type checker fails to report an error. #39852

Closed
mmaedel opened this issue Jun 25, 2020 · 3 comments
Closed

cmd/go2go: Looks like the type checker fails to report an error. #39852

mmaedel opened this issue Jun 25, 2020 · 3 comments

Comments

@mmaedel
Copy link

@mmaedel mmaedel commented Jun 25, 2020

Looks like the type checker fails to report an error.

Smaller test case:

package main

type Optional(type T) struct {
	p   T
	set bool
}

func (o Optional(T)) Val() (T, bool) {
	return o.p, true
}

type Box(type T) interface {
	Val() (T, bool)
}

func F1(type V interface{}, A, B Box(V))() {}

func main() {
	F1(int, Optional(int), Optional(string))()
}

This requires that both Optional(int) and Optional(string) implement Box(int). Optional(int) does implement it, but Optional(string) does not. The type checker passes this without error but probably should not.

Originally posted by @ianlancetaylor in #39754 (comment)

@mmaedel
Copy link
Author

@mmaedel mmaedel commented Jun 25, 2020

Hello

I am not able to confirm if this happens with the dev.go2go branch (https://go.googlesource.com/go/+/refs/heads/dev.go2go/README.go2go.md), because I did not build it.

But the following reproduces in the Go playground at https://go2goplay.golang.org:

with https://go2goplay.golang.org/p/SvjDqoK0Avc you get a program exit.

but with e.g.:

https://go2goplay.golang.org/p/4W1iYApaV74

or

https://go2goplay.golang.org/p/S9HkrNZ2YX-

...

you get an error message:

"type checking failed for main" + additional import failure

Not sure if this is an issue in the go2 branch.

regards Matthias

@cagedmantis cagedmantis added this to the Unreleased milestone Jun 25, 2020
@cagedmantis
Copy link
Contributor

@cagedmantis cagedmantis commented Jun 25, 2020

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Jun 25, 2020

Thanks, but this is already covered by #39754. We don't need another issue for it.

(When I said in #39754 that we should have a separate issue, I was referring to your comment, not to my comment.)

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.