You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a well-known problem: comments are placed based on their original source code positions and thus don't "flow" with the nodes they seem to be attached to (they are not attached). You can use an ast.CommentSet to work around this issue.
Unfortunately this is "working as intended" - and also one of the major reasons why the go/ast could use a major overhaul.
In golang.org/cl/12373, I wrote a cmd/fix rule to rewrite "types.Typ[x]" into "x.Basic()". However, the naive approach causes
to get formatted as
I.e., the godoc for g is moved up into the arguments section for the .Basic() invocation.
See http://play.golang.org/p/dwq4E8dsMW for a working example.Edit: See http://play.golang.org/p/CP8ylmNjmQ for an updated working example using ast.CommentMap.As a workaround, I found setting Rparen seems to prevent the issue. I wouldn't expect that to be necessary though.
The text was updated successfully, but these errors were encountered: