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: type parameters can omit any constraint #41042

Closed
changkun opened this issue Aug 26, 2020 · 3 comments
Closed

cmd/go2go: type parameters can omit any constraint #41042

changkun opened this issue Aug 26, 2020 · 3 comments

Comments

@changkun
Copy link
Member

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

$ go version
go version devel +1964d56295 Wed Aug 26 01:59:01 2020 +0000 darwin/amd64

What did you do?

According to the commit message of 1964d56:

all type parameters must have a constraint, can be "any"

However, given the following example:

// p.go2
package p

type I [T] interface {
	M() T
}

What did you expect to see?

Throw missing constraint error, e.g.

$ go tool go2go translate p.go2
p.go2:3:10: expected type constraint, found ']'

What did you see instead?

$ go tool go2go translate p.go2

Nothing thrown.

@ianlancetaylor
Copy link
Contributor

The experimental translation tool accepts a range of syntaxes. It does not strictly enforce the rules required by the design draft.

@changkun
Copy link
Member Author

changkun commented Aug 26, 2020

@ianlancetaylor But where to find a document for all possibilities without knowing the implementation details? How can one classify bugs apart from expected behaviors?

@ianlancetaylor
Copy link
Contributor

go2go is an experimental tool, and the main purpose of the tool is to see if the generics design draft provides the semantics that people need and want. The syntax is not the point of the tool. Report bugs where the behavior is not what you expect, or where you can't do what you want. Bugs about syntactic details are less interesting, because the syntax is much easier to change than the semantics.

That said, we will soon be updating the dev.go2go branch to default to only permitting the syntax described in the design draft.

Thanks.

@golang golang locked and limited conversation to collaborators Aug 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants