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

Comments

@komkom
Copy link

@komkom 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 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
Member

@dmitshur dmitshur commented Sep 3, 2020

@rsc
Copy link
Contributor

@rsc 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
Author

@komkom 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

@griesemer griesemer commented Sep 3, 2020

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.

@griesemer griesemer closed this Sep 3, 2020
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
4 participants
You can’t perform that action at this time.