Skip to content

Commit 2a7d0cd

Browse files
authored
Merge pull request #4661 from diffblue/smt2_arguments_check
smt2 frontend: check the number of types of function arguments
2 parents 32e5d4f + 25a0644 commit 2a7d0cd

File tree

4 files changed

+21
-12
lines changed

4 files changed

+21
-12
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
function-application3.smt2
3+
4+
^EXIT=20$
5+
^SIGNAL=0$
6+
^\(error "line 4: wrong number of arguments for function"\)$
7+
--
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
(set-logic LIA)
2+
3+
(define-fun next ((x Int)) Int x )
4+
(assert (= (next ) 243))
5+
6+
(check-sat)

src/solvers/smt2/smt2_parser.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -291,26 +291,22 @@ exprt smt2_parsert::quantifier_expression(irep_idt id)
291291
}
292292

293293
exprt smt2_parsert::function_application(
294-
const irep_idt &,
295-
const exprt::operandst &)
294+
const symbol_exprt &function,
295+
const exprt::operandst &op)
296296
{
297-
#if 0
298-
const auto &f = id_map[identifier];
297+
const auto &function_type = to_mathematical_function_type(function.type());
299298

300299
// check the arguments
301-
if(op.size()!=f.type.variables().size())
300+
if(op.size() != function_type.domain().size())
302301
throw error("wrong number of arguments for function");
303302

304303
for(std::size_t i=0; i<op.size(); i++)
305304
{
306-
if(op[i].type() != f.type.variables()[i].type())
305+
if(op[i].type() != function_type.domain()[i])
307306
throw error("wrong type for arguments for function");
308307
}
309308

310-
return function_application_exprt(
311-
symbol_exprt(identifier, f.type), op, f.type.range());
312-
#endif
313-
return nil_exprt();
309+
return function_application_exprt(function, op);
314310
}
315311

316312
exprt::operandst smt2_parsert::cast_bv_to_signed(const exprt::operandst &op)
@@ -826,7 +822,7 @@ exprt smt2_parsert::function_application()
826822
{
827823
if(id_it->second.type.id()==ID_mathematical_function)
828824
{
829-
return function_application_exprt(
825+
return function_application(
830826
symbol_exprt(final_id, id_it->second.type), op);
831827
}
832828
else

src/solvers/smt2/smt2_parser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ class smt2_parsert
136136
exprt let_expression();
137137
exprt quantifier_expression(irep_idt);
138138
exprt function_application(
139-
const irep_idt &identifier,
139+
const symbol_exprt &function,
140140
const exprt::operandst &op);
141141

142142
/// Apply typecast to signedbv to expressions in vector

0 commit comments

Comments
 (0)