Type and bounds check "x | y | z".

This commit is contained in:
Nigel Tao committed 2017-07-27 13:07:10 +10:00
1 parent eee67e083d
commit e1be6d9582
6 files changed
+75 -33

No files matched your search

+1 -1
View File
@@ -1118,7 +1118,7 @@ func (g *gen) writeExpr(n *a.Expr, rp replacementPolicy, pp parenthesesPolicy, d
return err
}
case t.FlagsAssociativeOp:
if err := g.writeExprAssociativeOp(n, rp, depth); err != nil {
if err := g.writeExprAssociativeOp(n, rp, pp, depth); err != nil {
return err
}
default:
+7 -1
View File
@@ -704,7 +704,10 @@ func (g *gen) writeExprAs(lhs *a.Expr, rhs *a.TypeExpr, rp replacementPolicy, de
return nil
}
func (g *gen) writeExprAssociativeOp(n *a.Expr, rp replacementPolicy, depth uint32) error {
func (g *gen) writeExprAssociativeOp(n *a.Expr, rp replacementPolicy, pp parenthesesPolicy, depth uint32) error {
if pp == parenthesesMandatory {
g.writeb('(')
}
opName := cOpNames[0xFF&n.ID0().Key()]
for i, o := range n.Args() {
if i != 0 {
@@ -714,6 +717,9 @@ func (g *gen) writeExprAssociativeOp(n *a.Expr, rp replacementPolicy, depth uint
return err
}
}
if pp == parenthesesMandatory {
g.writeb(')')
}
return nil
}