Call SetMBounds when bounds-checking expressions

This commit is contained in:
Nigel Tao committed 2018-07-07 18:15:28 +10:00
1 parent a506657c53
commit ba3b97ec69
2 files changed
+10 -2

No files matched your search

+6 -2
View File
@@ -62,6 +62,7 @@ var (
func init() {
zeroExpr.SetConstValue(zero)
zeroExpr.SetMBounds(a.Bounds{zero, zero})
zeroExpr.SetMType(typeExprIdeal)
}
@@ -704,7 +705,9 @@ func (q *checker) bcheckExpr(n *a.Expr, depth uint32) (a.Bounds, error) {
}
depth++
// TODO: check that n.MBounds() is {nil, nil}? Likewise for tcheck?
if b := n.MBounds(); b[0] != nil {
return b, nil
}
nb, err := q.bcheckExpr1(n, depth)
if err != nil {
@@ -726,7 +729,8 @@ func (q *checker) bcheckExpr(n *a.Expr, depth uint32) (a.Bounds, error) {
if err := q.optimizeNonSuspendible(n); err != nil {
return a.Bounds{}, err
}
// TODO: call n.SetMBounds.
n.SetMBounds(nb)
return nb, nil
}
+4
View File
@@ -346,6 +346,10 @@ func (q *checker) tcheckExpr(n *a.Expr, depth uint32) error {
}
depth++
if n.MType() != nil {
return nil
}
switch op := n.Operator(); {
case op.IsXUnaryOp():
return q.tcheckExprUnaryOp(n, depth)