go/printer: deletes or inserts AST types into code #33479
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
Forked from #31291.
We have found that
go/printer.Fprint
will delete broken code.An example of code being deleted: https://play.golang.org/p/WKRt74denE0.
We have also found that
go/printer.Fprint
will insert the string literalBadStmt
orBadExpr
in broken code that parses into*ast.BadStmts
or*ast.BadExprs
.An example of code being rewritten: https://play.golang.org/p/_BBrwbfAtEH.
This was discovered through using the function
go/format.Node
, which usesgo/printer.Fprint
. We noticed thatformat.Source
returns an error in such cases, which is the behavior I would expect. I would have expected thatformat.Source
andformat.Node
would behave the same on the same input.The text was updated successfully, but these errors were encountered: