golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
122.87k stars 17.52k forks source link

go/printer: unexpected handling of indented comment #12822

Open griesemer opened 8 years ago

griesemer commented 8 years ago

The comment was indented one extra tab stop beyond where it should be by gofmt.

Also unexpected, and the reason the bug was noticed: gofmt converts two spaces into two tabs here, which causes an unfortunate interaction with xxx (when not in tab mode) and probably other editors -- if you attempt to remove the extra indent and then re-run gofmt, you may be led to believe it's impossible to get the comment to line up as desired/expected.

package p

func f() {
    a =
        func(T1) T2 {
            return q
        }

        // Comment
    b =
        func(T1) T2 {
            return q
        }
}
rsc commented 8 years ago

Too late for Go 1.6.