Skip to content

Commit 8fb9cc3

Browse files
committed
printer: add comments for the rare condition case
1 parent 6c6c6f5 commit 8fb9cc3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

printer/expr.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ func (p *printer) binaryExpr(x *ast.BinaryExpr, prec1 int) {
4949
prec := opprec(x)
5050
if prec < prec1 {
5151
// parenthesis needed
52+
// Note: The parser inserts an ast.ParenExpr node; thus this case
53+
// can only occur if the AST is created in a different way.
5254
p.token(token.POPEN)
5355
p.expr(x)
5456
p.token(token.PCLOSE)
@@ -66,6 +68,8 @@ func (p *printer) unaryExpr(x *ast.UnaryExpr, prec1 int) {
6668
prec := opprec(x)
6769
if prec < prec1 {
6870
// parenthesis needed
71+
// Note: this case can only occcur if the AST is created manually and
72+
// the code should invalid code.
6973
p.token(token.POPEN)
7074
p.expr(x)
7175
p.token(token.PCLOSE)

0 commit comments

Comments
 (0)