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/gofmt: gofmt introduces a trailing comma in some type parameter lists where not needed #51548

Closed
griesemer opened this issue Mar 8, 2022 · 3 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@griesemer
Copy link
Contributor

Given

package p

func _[P *int]() {}

gofmt introduces a trailing comma:

package p

func _[P *int,]() {}

This trailing comma (or an enclosing interface) is required to avoid a parsing ambiguity for generic types, but it's not needed for generic functions.

While not really a release blocker we should probably fix this before the release to avoid potential unnecessary code churn due to formatting changes down the road.

cc: @findleyr

@griesemer griesemer added the NeedsFix The path to resolution is known, but the work has not been done. label Mar 8, 2022
@griesemer griesemer added this to the Go1.18 milestone Mar 8, 2022
@findleyr
Copy link
Contributor

findleyr commented Mar 8, 2022

Thanks, I'll take a look at this.

@findleyr findleyr self-assigned this Mar 8, 2022
@gopherbot
Copy link

Change https://go.dev/cl/390914 mentions this issue: go/printer: don't print unnecesary commas for func type param lists

@gopherbot
Copy link

Change https://go.dev/cl/390957 mentions this issue: [release-branch.go1.18] go/printer: don't print unnecesary commas for func type param lists

gopherbot pushed a commit that referenced this issue Mar 9, 2022
… func type param lists

Type parameter lists are not ambiguous for function declarations in the
way that they are ambiguous for type declarations. Avoid printing an
extra comma to disambiguate.

Fixes #51548

Change-Id: I8ca2b21e271982013653b9e220f92ee74f577ba2
Reviewed-on: https://go-review.googlesource.com/c/go/+/390914
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
(cherry picked from commit 0add064)
Reviewed-on: https://go-review.googlesource.com/c/go/+/390957
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
@golang golang locked and limited conversation to collaborators Jun 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants