Fix associative op const-value calculation

This commit is contained in:
Nigel Tao committed 2020-02-08 14:54:00 +11:00
1 parent 8d29cb15ce
commit fb9a0964a2
4 files changed
+84 -9

No files matched your search

+4 -1
View File
@@ -495,7 +495,7 @@ func (q *checker) bcheckAssignment(lhs *a.Expr, op t.ID, rhs *a.Expr) error {
func (q *checker) bcheckAssignment1(lhs *a.Expr, lTyp *a.TypeExpr, op t.ID, rhs *a.Expr) (bounds, error) {
if lhs == nil && op != t.IDEq {
return bounds{}, fmt.Errorf("check: internal error: missing LHS for op key 0x%02X", op)
return bounds{}, fmt.Errorf("check: internal error: missing LHS for op key 0x%X", op)
}
lb, err := bounds{}, (error)(nil)
@@ -795,6 +795,9 @@ func bcheckExprConstValue(n *a.Expr) bounds {
if o := n.RHS(); o != nil && n.Operator() != t.IDXBinaryAs {
bcheckExprConstValue(o.AsExpr())
}
for _, o := range n.Args() {
bcheckExprConstValue(o.AsExpr())
}
cv := n.ConstValue()
b := bounds{cv, cv}
n.SetMBounds(b)