Skip to content

cmd/gofmt: incorrect indentation of comments for LabeledStmt #27964

@dave

Description

@dave

Please answer these questions before submitting your issue. Thanks!

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

go1.11

Does this issue reproduce with the latest release?

Yes

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

darwin/amd64

What did you do?

If a LabeledStmt has an inline comment before and after the Colon, then an inline comment on the previous line will be indented incorrectly:

https://play.golang.org/p/mSDEYsc_34O

This code should not change with gofmt:

package main

func main() {

	/* comment */
L /* long comment */ : /* comment */
	print("foo")

	goto L

}

... however it changes to:

package main

func main() {

			/* comment */
L /* long comment */ : /* comment */
	print("foo")

	goto L

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions