Rename some TypeExprFoo variables.

This commit is contained in:
Nigel Tao committed 2017-06-03 12:28:19 +10:00
1 parent 1758637f89
commit 40229f0158
3 files changed
+22 -22

No files matched your search

+16 -16
View File
@@ -56,7 +56,7 @@ func (q *checker) tcheckStatement(n *a.Node) error {
if err := q.tcheckExpr(cond, 0); err != nil {
return err
}
if !cond.MType().Eq(TypeExprBoolean) {
if !cond.MType().Eq(TypeExprBool) {
return fmt.Errorf("check: if condition %q, of type %q, does not have a boolean type",
cond.String(q.idMap), cond.MType().String(q.idMap))
}
@@ -128,7 +128,7 @@ func (q *checker) tcheckStatement(n *a.Node) error {
if err := q.tcheckExpr(cond, 0); err != nil {
return err
}
if !cond.MType().Eq(TypeExprBoolean) {
if !cond.MType().Eq(TypeExprBool) {
return fmt.Errorf("check: for-loop condition %q, of type %q, does not have a boolean type",
cond.String(q.idMap), cond.MType().String(q.idMap))
}
@@ -161,7 +161,7 @@ func (q *checker) tcheckAssert(n *a.Assert) error {
if err := q.tcheckExpr(cond, 0); err != nil {
return err
}
if !cond.MType().Eq(TypeExprBoolean) {
if !cond.MType().Eq(TypeExprBool) {
return fmt.Errorf("check: assert condition %q, of type %q, does not have a boolean type",
cond.String(q.idMap), cond.MType().String(q.idMap))
}
@@ -188,7 +188,7 @@ func (q *checker) tcheckAssign(n *a.Assign) error {
rTyp := rhs.MType()
if n.Operator().Key() == t.KeyEq {
if (rTyp == TypeExprIdealNumber && lTyp.IsNumType()) || lTyp.EqIgnoringRefinements(rTyp) {
if (rTyp == TypeExprIdeal && lTyp.IsNumType()) || lTyp.EqIgnoringRefinements(rTyp) {
return nil
}
return fmt.Errorf("check: cannot assign %q of type %q to %q of type %q",
@@ -209,7 +209,7 @@ func (q *checker) tcheckAssign(n *a.Assign) error {
n.Operator().String(q.idMap), rhs.String(q.idMap), rTyp.String(q.idMap))
}
if rTyp == TypeExprIdealNumber || lTyp.EqIgnoringRefinements(rTyp) {
if rTyp == TypeExprIdeal || lTyp.EqIgnoringRefinements(rTyp) {
return nil
}
return fmt.Errorf("check: assignment %q: %q and %q, of types %q and %q, do not have compatible types",
@@ -260,7 +260,7 @@ func (q *checker) tcheckExprOther(n *a.Expr, depth uint32) error {
return fmt.Errorf("check: invalid numeric literal %q", s)
}
n.SetConstValue(z)
n.SetMType(TypeExprIdealNumber)
n.SetMType(TypeExprIdeal)
return nil
} else if id1.IsIdent() {
@@ -276,12 +276,12 @@ func (q *checker) tcheckExprOther(n *a.Expr, depth uint32) error {
switch id1.Key() {
case t.KeyFalse:
n.SetConstValue(zero)
n.SetMType(TypeExprBoolean)
n.SetMType(TypeExprBool)
return nil
case t.KeyTrue:
n.SetConstValue(one)
n.SetMType(TypeExprBoolean)
n.SetMType(TypeExprBool)
return nil
case t.KeyUnderscore:
@@ -400,14 +400,14 @@ func (q *checker) tcheckExprUnaryOp(n *a.Expr, depth uint32) error {
return nil
case t.KeyXUnaryNot:
if !rTyp.Eq(TypeExprBoolean) {
if !rTyp.Eq(TypeExprBool) {
return fmt.Errorf("check: unary %q: %q, of type %q, does not have a boolean type",
n.ID0().AmbiguousForm().String(q.idMap), rhs.String(q.idMap), rTyp.String(q.idMap))
}
if cv := rhs.ConstValue(); cv != nil {
n.SetConstValue(btoi(cv.Cmp(zero) == 0))
}
n.SetMType(TypeExprBoolean)
n.SetMType(TypeExprBool)
return nil
}
return fmt.Errorf("check: unrecognized token.Key (0x%X) for tcheckExprUnaryOp", n.ID0().Key())
@@ -451,11 +451,11 @@ func (q *checker) tcheckExprBinaryOp(n *a.Expr, depth uint32) error {
case t.KeyXBinaryNotEq, t.KeyXBinaryEqEq:
// No-op.
case t.KeyXBinaryAnd, t.KeyXBinaryOr:
if lTyp != TypeExprBoolean {
if lTyp != TypeExprBool {
return fmt.Errorf("check: binary %q: %q, of type %q, does not have a boolean type",
op.AmbiguousForm().String(q.idMap), lhs.String(q.idMap), lTyp.String(q.idMap))
}
if rTyp != TypeExprBoolean {
if rTyp != TypeExprBool {
return fmt.Errorf("check: binary %q: %q, of type %q, does not have a boolean type",
op.AmbiguousForm().String(q.idMap), rhs.String(q.idMap), rTyp.String(q.idMap))
}
@@ -463,7 +463,7 @@ func (q *checker) tcheckExprBinaryOp(n *a.Expr, depth uint32) error {
switch op.Key() {
default:
if !lTyp.EqIgnoringRefinements(rTyp) && lTyp != TypeExprIdealNumber && rTyp != TypeExprIdealNumber {
if !lTyp.EqIgnoringRefinements(rTyp) && lTyp != TypeExprIdeal && rTyp != TypeExprIdeal {
return fmt.Errorf("check: binary %q: %q and %q, of types %q and %q, do not have compatible types",
op.AmbiguousForm().String(q.idMap),
lhs.String(q.idMap), rhs.String(q.idMap),
@@ -471,7 +471,7 @@ func (q *checker) tcheckExprBinaryOp(n *a.Expr, depth uint32) error {
)
}
case t.KeyXBinaryShiftL, t.KeyXBinaryShiftR:
if (lTyp == TypeExprIdealNumber) && (rTyp != TypeExprIdealNumber) {
if (lTyp == TypeExprIdeal) && (rTyp != TypeExprIdeal) {
return fmt.Errorf("check: binary %q: %q and %q, of types %q and %q; "+
"cannot shift an ideal number by a non-ideal number",
op.AmbiguousForm().String(q.idMap),
@@ -488,8 +488,8 @@ func (q *checker) tcheckExprBinaryOp(n *a.Expr, depth uint32) error {
}
if comparisonOps[0xFF&op.Key()] {
n.SetMType(TypeExprBoolean)
} else if lTyp != TypeExprIdealNumber {
n.SetMType(TypeExprBool)
} else if lTyp != TypeExprIdeal {
n.SetMType(lTyp)
} else {
n.SetMType(rTyp)