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

Comments

@rogpeppe
Copy link
Contributor

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 commented Aug 14, 2020

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

@ianlancetaylor
Copy link
Contributor

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.

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

4 participants