File tree Expand file tree Collapse file tree 5 files changed +61
-0
lines changed
regression/smt2_solver/function-applications Expand file tree Collapse file tree 5 files changed +61
-0
lines changed Original file line number Diff line number Diff line change
1
+ CORE
2
+ function-application1.smt2
3
+
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^unsat$
7
+ --
Original file line number Diff line number Diff line change
1
+ (set-logic QF_BV)
2
+
3
+ (define-fun min ((a (_ BitVec 8 )) (b (_ BitVec 8 ))) (_ BitVec 8 )
4
+ (ite (bvule a b) a b))
5
+
6
+ (define-fun p1 () Bool (= (min #x01 #x02 ) #x01 ))
7
+ (define-fun p2 () Bool (= (min #xff #xfe ) #xfe ))
8
+
9
+ ; all must be true
10
+
11
+ (assert (not (and p1 p2)))
12
+
13
+ (check-sat )
Original file line number Diff line number Diff line change
1
+ CORE
2
+ function-application2.smt2
3
+
4
+ ^EXIT=134$
5
+ ^SIGNAL=0$
6
+ ^line 5: type mismatch in function definition: expected `\(_ BitVec 16\)' but got `\(_ BitVec 8\)'$
7
+ --
Original file line number Diff line number Diff line change
1
+ (set-logic QF_BV)
2
+
3
+ ; the range type doesn't match!
4
+ (define-fun min ((a (_ BitVec 8 )) (b (_ BitVec 8 ))) (_ BitVec 16 )
5
+ (ite (bvule a b) a b))
6
+
7
+ (define-fun p1 () Bool (= (min #x01 #x02 ) #x01 ))
8
+ (define-fun p2 () Bool (= (min #xff #xfe ) #xfe ))
9
+
10
+ ; all must be true
11
+
12
+ (assert (not (and p1 p2)))
13
+
14
+ (check-sat )
Original file line number Diff line number Diff line change @@ -1203,6 +1203,26 @@ void smt2_parsert::command(const std::string &c)
1203
1203
auto signature=function_signature_definition ();
1204
1204
exprt body=expression ();
1205
1205
1206
+ // check type of body
1207
+ if (signature.id () == ID_mathematical_function)
1208
+ {
1209
+ const auto &f_signature = to_mathematical_function_type (signature);
1210
+ if (body.type () != f_signature.codomain ())
1211
+ {
1212
+ error () << " type mismatch in function definition: expected `"
1213
+ << smt2_format (f_signature.codomain ()) << " ' but got `"
1214
+ << smt2_format (body.type ()) << ' \' ' << eom;
1215
+ return ;
1216
+ }
1217
+ }
1218
+ else if (body.type () != signature)
1219
+ {
1220
+ error () << " type mismatch in function definition: expected `"
1221
+ << smt2_format (signature) << " ' but got `"
1222
+ << smt2_format (body.type ()) << ' \' ' << eom;
1223
+ return ;
1224
+ }
1225
+
1206
1226
// set up the entry
1207
1227
auto &entry=id_map[id];
1208
1228
entry.type =signature;
You can’t perform that action at this time.
0 commit comments