Improved type-checking for tuple and record selects.
authorMorgan Deters <mdeters@cs.nyu.edu>
Tue, 27 May 2014 04:06:42 +0000 (00:06 -0400)
committerMorgan Deters <mdeters@cs.nyu.edu>
Tue, 27 May 2014 14:57:16 +0000 (10:57 -0400)
src/theory/datatypes/theory_datatypes_type_rules.h

index d08b511dd431b7f44e28e19c79d1edb665e804d3..09d43b3bc5ff8d91fda62250925138e38ff019a9 100644 (file)
@@ -282,6 +282,9 @@ struct TupleTypeRule {
 struct TupleSelectTypeRule {
   inline static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check) {
     Assert(n.getKind() == kind::TUPLE_SELECT);
+    if(n.getOperator().getKind() != kind::TUPLE_SELECT_OP) {
+      throw TypeCheckingExceptionPrivate(n, "Tuple-select expression requires TupleSelect operator");
+    }
     const TupleSelect& ts = n.getOperator().getConst<TupleSelect>();
     TypeNode tupleType = n[0].getType(check);
     if(!tupleType.isTuple()) {
@@ -422,6 +425,9 @@ struct RecordSelectTypeRule {
   inline static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check) {
     Assert(n.getKind() == kind::RECORD_SELECT);
     NodeManagerScope nms(nodeManager);
+    if(n.getOperator().getKind() != kind::RECORD_SELECT_OP) {
+      throw TypeCheckingExceptionPrivate(n, "Tuple-select expression requires TupleSelect operator");
+    }
     const RecordSelect& rs = n.getOperator().getConst<RecordSelect>();
     TypeNode recordType = n[0].getType(check);
     if(!recordType.isRecord()) {