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
Contributor

@changkun changkun commented Aug 26, 2020

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

@ianlancetaylor ianlancetaylor commented Aug 26, 2020

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

@changkun
Copy link
Contributor Author

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

@ianlancetaylor ianlancetaylor commented Aug 26, 2020

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.

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
2 participants
You can’t perform that action at this time.