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/compile/internal/syntax: unclear error message for function type have type parameters #48382

Open
cuonglm opened this issue Sep 14, 2021 · 1 comment
Assignees
Labels
Milestone

Comments

@cuonglm
Copy link
Member

@cuonglm cuonglm commented Sep 14, 2021

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

$ go version
go version devel go1.18-ee91bb8319 Tue Sep 14 02:53:17 2021 +0000 darwin/arm64

Does this issue reproduce with the latest release?

What operating system and processor architecture are you using (go env)?

go env Output
$ go env

What did you do?

Compile this program:

package p

type I func[T any]()

What did you expect to see?

Friendly error message, like gotype:

$ gotype p.go
p.go:3:12: function type cannot have type parameters

What did you see instead?

$ go tool compile p.go
p.go:3:15: syntax error: unexpected any, expecting ]

cc @griesemer @findleyr

@cuonglm cuonglm added this to the Go1.18 milestone Sep 14, 2021
@cuonglm cuonglm changed the title cmd/compile/internal/syntax cmd/compile/internal/syntax: unclear error message for function type have type parameters Sep 14, 2021
@griesemer griesemer self-assigned this Sep 14, 2021
@griesemer
Copy link
Contributor

@griesemer griesemer commented Sep 14, 2021

The fix is not hard but it's also subtle due to the way func type parsing is used in various places. If we address this, it needs to be a comprehensive fix which requires some careful parser changes.

Not urgent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants