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: square bracket syntax doesn't work for multiple type arguments #40788

Closed
rogpeppe opened this issue Aug 14, 2020 · 2 comments
Closed

cmd/go2go: square bracket syntax doesn't work for multiple type arguments #40788

rogpeppe opened this issue Aug 14, 2020 · 2 comments

Comments

@rogpeppe
Copy link
Contributor

@rogpeppe rogpeppe commented Aug 14, 2020

commit 722af87

The following program gives a syntax error. Using the round bracket syntax for instantiating the function works as expected. It appears that the parser doesn't allow the new square bracket syntax with multiple type parameters.

package main
import "fmt"

func main() {
	fmt.Println(double[int, int](24, 56))
}

func double[type T, S](x S, y T) (S, T) {
	return x, y
}
@ainar-g
Copy link
Contributor

@ainar-g ainar-g commented Aug 14, 2020

It seems to work if the declaration of double precedes its first use.

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Aug 14, 2020

The parser currently decides that it will use square brackets based on the first parameterized declaration. If the first use of square brackets it is a use rather than a declaration, it doesn't always understand it. This is a temporary hack until we settle on a syntax.

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