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: unexpected successful compilation #41203

Closed
komkom opened this issue Sep 3, 2020 · 4 comments
Closed

cmd/go2go: unexpected successful compilation #41203

komkom opened this issue Sep 3, 2020 · 4 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@komkom
Copy link
Contributor

komkom commented Sep 3, 2020

What version of Go are you using (go version)?

https://go2goplay.golang.org/

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

google chrome

What did you do?

I wrote the following
https://go2goplay.golang.org/p/30SD7t_sLOa

What did you expect to see?

To see a compilation error.
Or is this expected to compile and go vet will warn about it?

What did you see instead?

Successful compilation

@dmitshur dmitshur added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Sep 3, 2020
@dmitshur dmitshur added this to the Unreleased milestone Sep 3, 2020
@dmitshur dmitshur changed the title unexpected successful compilation with go2 cmd/go2go: unexpected successful compilation Sep 3, 2020
@dmitshur
Copy link
Contributor

dmitshur commented Sep 3, 2020

/cc @griesemer @ianlancetaylor

@rsc
Copy link
Contributor

rsc commented Sep 3, 2020

I don't believe it is an error to write an unsatisfiable constraint. The design draft even gives an example.
But the one in your program looks perfectly satisfiable to me:

https://go2goplay.golang.org/p/vdIhKL71Lyt

@komkom
Copy link
Contributor Author

komkom commented Sep 3, 2020

Thanks for this!
But isn't it strange that it is possible to have code with unsatisfiable constraints. Shouldn't it be possible to detect this?
BTW in the example above I was missing that I[X] can implement the same interface as X.
So is this a correct example for an unsatisfiable constraint https://go2goplay.golang.org/p/YrPhYRchDSH ?

@griesemer
Copy link
Contributor

As @rsc pointed out, it is perfectly fine to write constraints that cannot be satisfied. (As an aside, your example can be satisfied: https://go2goplay.golang.org/p/VO-7h04CiAd .) This is not an issue with the prototype; it is permitted by the design draft.

Your 2nd example's constraint can also be satisfied: https://go2goplay.golang.org/p/nkhNZ1cBx-f.

Even in non-generic Go it is possible to write nonsensical code.

@golang golang locked and limited conversation to collaborators Sep 3, 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

5 participants