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
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@mmaedel
Copy link

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 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 the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jun 25, 2020
@cagedmantis cagedmantis added this to the Unreleased milestone Jun 25, 2020
@cagedmantis
Copy link
Contributor

/cc @griesemer @ianlancetaylor

@ianlancetaylor
Copy link
Contributor

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.)

@golang golang locked and limited conversation to collaborators Jun 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants