Check "i < j" when i's type refines j's type.

This commit is contained in:
Nigel Tao committed 2017-05-13 10:40:48 +10:00
1 parent 87dcd9ed55
commit 7367a382b2
4 files changed
+27 -8

No files matched your search

+3 -3
View File
@@ -67,7 +67,7 @@ func (c *typeChecker) checkStatement(n *a.Node) error {
lTyp := l.MType()
rTyp := r.MType()
// TODO, look at o.Operator().
if (rTyp == TypeExprIdealNumber && lTyp.IsNumType()) || lTyp.Eq(rTyp) {
if (rTyp == TypeExprIdealNumber && lTyp.IsNumType()) || lTyp.EqIgnoringRefinements(rTyp) {
return nil
}
return fmt.Errorf("check: cannot assign %q of type %q to %q of type %q",
@@ -301,8 +301,8 @@ func (c *typeChecker) checkExprBinaryOp(n *a.Expr) error {
switch op {
default:
if !lTyp.Eq(rTyp) && lTyp != TypeExprIdealNumber && rTyp != TypeExprIdealNumber {
return fmt.Errorf("check: binary %q: %q and %q, of types %q and %q, does not have compatible types",
if !lTyp.EqIgnoringRefinements(rTyp) && lTyp != TypeExprIdealNumber && rTyp != TypeExprIdealNumber {
return fmt.Errorf("check: binary %q: %q and %q, of types %q and %q, do not have compatible types",
c.idMap.ByID(op.AmbiguousForm()),
lhs.String(c.idMap), rhs.String(c.idMap),
lTyp.String(c.idMap), rTyp.String(c.idMap),