diff --git a/lang/check/bounds.go b/lang/check/bounds.go index a162962f..d0a25e8d 100644 --- a/lang/check/bounds.go +++ b/lang/check/bounds.go @@ -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 } diff --git a/lang/check/type.go b/lang/check/type.go index 15c34494..d4626611 100644 --- a/lang/check/type.go +++ b/lang/check/type.go @@ -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)