go/printer: "Line of stars" detection false positive for commented out block of code with each line dereferencing a pointer. #12164
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (go version)?
What operating system and processor architecture are you using?
OS X 10.10.5, amd64.
What did you do?
Consider the following program:
If you comment out the first block of code and run
gofmt
on it, you get:However, if you comment out the second block of code like this:
What did you expect to see?
After formatting the above code with
gofmt
, I would expect it to be formatted similarly to when any other piece of code is commented out, so it should be:What did you see instead?
Which is not consistent with anything.
I'm pretty sure I know why it happens. It has to do with go/printer detecting a so called "line of stars" style of comments, which normally look like this:
See relevant code at
go/src/go/printer/printer.go
Lines 529 to 539 in 467a2cb
However, in this case, it's not a comment block because there is no space after the * as in normally formatted comments, it's just commented out code that happens to falsely trigger the line of stars comment block handling.
The text was updated successfully, but these errors were encountered: