cmd/gofmt: unfinished else statement followed by if statement should maybe have indentation #26701
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
)?Does this issue reproduce with the latest release?
Yep
What operating system and processor architecture are you using (
go env
)?What did you do?
Started writing an
else
statement but got distracted fixing an issue elsewhere in the program and didn't finish the statement. Definitely my bad! However, gofmt made this bug a little harder to find:https://play.golang.org/p/AdIDE1dT9Sd
Notice that the next statement is an
if
, with a comment between them. Because of the comment.go fmt
didn't move theif
up to the line with theelse
. That seems correct, however, since it is technically a continuation of theelse
, indenting theif
would have been helpful for catching it.What did you expect to see?
What did you see instead?
This is just a proposed enhancement -- not urgent, and definitely still my fault for not finishing a line I started -- but if
gofmt
could figure this out and cue me in by indenting, that would be helpful. :)Edit: Seems similar to #20562 -- at least one of the comments there mentions the same issue, it looks like. Feel free to close if you think this is a duplicate. I can't quite tell if that's a separate formatting issue originally...
The text was updated successfully, but these errors were encountered: