-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/gofmt: rewrite might eat comments when given statement #6099
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
Labels
Comments
2-3 Two things at play here. 1) https://golang.org/cl/6294076/ added removal of comments to gofmt -r. It only keeps comments for which a node exists in the new AST 2) 'x := s.foo[y] -> x := s.foo.Get(y)' seems to get interpreted as 'x -> x', replacing every identifier/expression with itself 3) Due to the way equality is checked (map lookup with ast.Node's as keys), the replacements aren't equal to the old nodes, causing all attached comments to be lost. |
Owner changed to @griesemer. |
This is partly addressed with https://golang.org/cl/68920044 : gofmt -r 'x := s.foo[y] -> x := s.foo.Get(y)' now complains that the expression pattern is incorrect. Thanks to dominik.honnef for analyzing the case. |
The before mentioned CL fixes the confusion (per dominik.honnef's suggestion. Closing this in favor of the more specific issue #7417. Status changed to Fixed. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: