This PR should be added before the minor release that advertises our policy change for subtyping.
if (!d_match[index].isNull())
{
Trace("typecheck-idt")
- << "check subtype " << tn << " " << d_match[index] << std::endl;
- TypeNode tnn = TypeNode::leastCommonTypeNode(tn, d_match[index]);
- // recognize subtype relation
- if (!tnn.isNull())
+ << "check types " << tn << " " << d_match[index] << std::endl;
+ if (tn != d_match[index])
{
- d_match[index] = tnn;
- return true;
+ return false;
}
- return false;
+ d_match[index] = tn;
+ return true;
}
d_match[index] = tn;
return true;
}
else
{
- Assert (isReal);
+ Assert(isReal);
out << "(/ ";
if (neg)
{
if (check)
{
Assert(n.getNumChildren() == 2);
- TypeNode t1 = n[0].getType(check);
- if (!t1.isRealOrInt())
+ if (!n[0].getType(check).isRealOrInt()
+ || !n[1].getType(check).isRealOrInt())
{
throw TypeCheckingExceptionPrivate(
n, "expecting an arithmetic term for arithmetic relation");
}
- TypeNode t2 = n[1].getType(check);
- if (!t1.isComparableTo(t2))
- {
- throw TypeCheckingExceptionPrivate(
- n, "expecting arithmetic terms of comparable type");
- }
}
return nodeManager->booleanType();
}
"array select operating on non-array");
}
TypeNode indexType = n[1].getType(check);
- if (!indexType.isSubtypeOf(arrayType.getArrayIndexType()))
+ if (indexType != arrayType.getArrayIndexType())
{
throw TypeCheckingExceptionPrivate(
n, "array select not indexed with correct type for array");
"array table fun arg 1 is non-array");
}
TypeNode indexType = n[2].getType(check);
- if (!indexType.isComparableTo(arrayType.getArrayIndexType()))
+ if (indexType != arrayType.getArrayIndexType())
{
throw TypeCheckingExceptionPrivate(
n, "array table fun arg 2 does not match type of array");
}
indexType = n[3].getType(check);
- if (!indexType.isComparableTo(arrayType.getArrayIndexType()))
+ if (indexType != arrayType.getArrayIndexType())
{
throw TypeCheckingExceptionPrivate(
n, "array table fun arg 3 does not match type of array");
TypeNode secondBagType = n[1].getType(check);
if (secondBagType != bagType)
{
- if (!bagType.isComparableTo(secondBagType))
- {
- throw TypeCheckingExceptionPrivate(
- n, "BAG_SUBBAG operating on bags of different types");
- }
+ throw TypeCheckingExceptionPrivate(
+ n, "BAG_SUBBAG operating on bags of different types");
}
}
return nodeManager->booleanType();
TypeNode elementType = n[0].getType(check);
// e.g. (bag.count 1 (bag (BagMakeOp Real) 1.0 3))) is 3 whereas
// (bag.count 1.0 (bag (BagMakeOp Int) 1 3)) throws a typing error
- if (!elementType.isSubtypeOf(bagType.getBagElementType()))
+ if (elementType != bagType.getBagElementType())
{
std::stringstream ss;
ss << "member operating on bags of different types:\n"
<< "child type: " << elementType << "\n"
- << "not subtype: " << bagType.getBagElementType() << "\n"
+ << "not type: " << bagType.getBagElementType() << "\n"
<< "in term : " << n;
throw TypeCheckingExceptionPrivate(n, ss.str());
}
TypeNode elementType = n[0].getType(check);
// e.g. (bag.member 1 (bag 1.0 1)) is true whereas
// (bag.member 1.0 (bag 1 1)) throws a typing error
- if (!elementType.isSubtypeOf(bagType.getBagElementType()))
+ if (elementType != bagType.getBagElementType())
{
std::stringstream ss;
ss << "member operating on bags of different types:\n"
<< "child type: " << elementType << "\n"
- << "not subtype: " << bagType.getBagElementType() << "\n"
+ << "not type: " << bagType.getBagElementType() << "\n"
<< "in term : " << n;
throw TypeCheckingExceptionPrivate(n, ss.str());
}
TypeNode actualElementType = n[0].getType(check);
// the type of the element should be a subtype of the type of the operator
// e.g. (bag (bag_op Real) 1 1) where 1 is an Int
- if (!actualElementType.isSubtypeOf(expectedElementType))
+ if (actualElementType != expectedElementType)
{
std::stringstream ss;
ss << "The type '" << actualElementType
- << "' of the element is not a subtype of '" << expectedElementType
+ << "' of the element is not type of '" << expectedElementType
<< "' in term : " << n;
throw TypeCheckingExceptionPrivate(n, ss.str());
}
}
std::vector<TypeNode> argTypes = functionType.getArgTypes();
TypeNode rangeType = functionType.getRangeType();
- if (!(argTypes.size() == 2 && elementType.isSubtypeOf(argTypes[0])
- && elementType.isSubtypeOf(argTypes[1])
- && rangeType == nm->booleanType()))
+ if (!(argTypes.size() == 2 && elementType == argTypes[0]
+ && elementType == argTypes[1] && rangeType == nm->booleanType()))
{
std::stringstream ss;
ss << "Operator " << n.getKind() << " expects a function of type (-> "
Trace("typecheck-idt") << "typecheck cons arg: " << childType << " "
<< (*tchild_it) << std::endl;
TypeNode argumentType = *tchild_it;
- if (!childType.isSubtypeOf(argumentType))
+ if (childType != argumentType)
{
std::stringstream ss;
ss << "bad type for constructor argument:\n"
<< "child type: " << childType << "\n"
- << "not subtype: " << argumentType << "\n"
+ << "not type: " << argumentType << "\n"
<< "in term : " << n;
throw TypeCheckingExceptionPrivate(n, ss.str());
}
Trace("typecheck-idt") << "typecheck sel: " << n << std::endl;
Trace("typecheck-idt") << "sel type: " << selType << std::endl;
TypeNode childType = n[0].getType(check);
- if (!selType[0].isComparableTo(childType))
+ if (selType[0] != childType)
{
Trace("typecheck-idt") << "ERROR: " << selType[0].getKind() << " "
<< childType.getKind() << std::endl;
{
Trace("typecheck-idt") << "typecheck test: " << n << std::endl;
Trace("typecheck-idt") << "test type: " << testType << std::endl;
- if (!testType[0].isComparableTo(childType))
+ if (testType[0] != childType)
{
throw TypeCheckingExceptionPrivate(n, "bad type for tester argument");
}
"matching failed for update argument of parameterized datatype");
}
}
- else
+ else if (targ != childType)
{
- if (!targ.isComparableTo(childType))
- {
- throw TypeCheckingExceptionPrivate(n, "bad type for update argument");
- }
+ throw TypeCheckingExceptionPrivate(n, "bad type for update argument");
}
}
}
{
TypeNode vtype = svl[i].getType(check);
TypeNode atype = n[i + 1].getType(check);
- if (!vtype.isComparableTo(atype))
+ if (vtype != atype)
{
throw TypeCheckingExceptionPrivate(
n,
{
retType = currType;
}
- else
+ else if (retType != currType)
{
- retType = TypeNode::leastCommonTypeNode(retType, currType);
- if (retType.isNull())
- {
- throw TypeCheckingExceptionPrivate(
- n, "incomparable types in match case list");
- }
+ throw TypeCheckingExceptionPrivate(
+ n, "incomparable types in match case list");
}
}
// it is mandatory to check this here to ensure the match is exhaustive
TypeNode secondSetType = n[1].getType(check);
if (secondSetType != setType)
{
- if (!setType.isComparableTo(secondSetType))
- {
- throw TypeCheckingExceptionPrivate(
- n, "set subset operating on sets of different types");
- }
+ throw TypeCheckingExceptionPrivate(
+ n, "set subset operating on sets of different types");
}
}
return nodeManager->booleanType();
TypeNode elementType = n[0].getType(check);
// e.g. (member 1 (singleton 1.0)) is true whereas
// (member 1.0 (singleton 1)) throws a typing error
- if (!elementType.isSubtypeOf(setType.getSetElementType()))
+ if (elementType != setType.getSetElementType())
{
std::stringstream ss;
ss << "member operating on sets of different types:\n"
<< "child type: " << elementType << "\n"
- << "not subtype: " << setType.getSetElementType() << "\n"
+ << "not type: " << setType.getSetElementType() << "\n"
<< "in term : " << n;
throw TypeCheckingExceptionPrivate(n, ss.str());
}
if (check)
{
TypeNode type2 = n[0].getType(check);
- TypeNode leastCommonType = TypeNode::leastCommonTypeNode(type1, type2);
// the type of the element should be a subtype of the type of the operator
// e.g. (set.singleton (SetSingletonOp Real) 1) where 1 is an Int
- if (leastCommonType.isNull() || leastCommonType != type1)
+ if (type1 != type2)
{
std::stringstream ss;
- ss << "The type '" << type2 << "' of the element is not a subtype of '"
+ ss << "The type '" << type2 << "' of the element is not a type of '"
<< type1 << "' in term : " << n;
throw TypeCheckingExceptionPrivate(n, ss.str());
}
TypeNode argType = n[0].getType(check);
// the type of the element should be a subtype of the type of the operator
// e.g. (seq.unit (SeqUnitOp Real) 1) where 1 is an Int
- if (!argType.isSubtypeOf(otype))
+ if (argType != otype)
{
std::stringstream ss;
- ss << "The type '" << argType << "' of the element is not a subtype of '"
+ ss << "The type '" << argType << "' of the element is not the type of '"
<< otype << "' in term : " << n;
throw TypeCheckingExceptionPrivate(n, ss.str());
}
if (check)
{
TypeNode aType = n[1].getType(check);
- if (!aType.isSubtypeOf(fType[0]))
+ if (aType != fType[0])
{
throw TypeCheckingExceptionPrivate(
n, "argument does not match function type");