Skip to content

smt2 frontend: check the number of types of function arguments #4661

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CORE
function-application3.smt2

^EXIT=20$
^SIGNAL=0$
^\(error "line 4: wrong number of arguments for function"\)$
--
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(set-logic LIA)

(define-fun next ((x Int)) Int x )
(assert (= (next ) 243))

(check-sat)
18 changes: 7 additions & 11 deletions src/solvers/smt2/smt2_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,26 +291,22 @@ exprt smt2_parsert::quantifier_expression(irep_idt id)
}

exprt smt2_parsert::function_application(
const irep_idt &,
const exprt::operandst &)
const symbol_exprt &function,
const exprt::operandst &op)
{
#if 0
const auto &f = id_map[identifier];
const auto &function_type = to_mathematical_function_type(function.type());

// check the arguments
if(op.size()!=f.type.variables().size())
if(op.size() != function_type.domain().size())
throw error("wrong number of arguments for function");

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

return function_application_exprt(
symbol_exprt(identifier, f.type), op, f.type.range());
#endif
return nil_exprt();
return function_application_exprt(function, op);
}

exprt::operandst smt2_parsert::cast_bv_to_signed(const exprt::operandst &op)
Expand Down Expand Up @@ -826,7 +822,7 @@ exprt smt2_parsert::function_application()
{
if(id_it->second.type.id()==ID_mathematical_function)
{
return function_application_exprt(
return function_application(
symbol_exprt(final_id, id_it->second.type), op);
}
else
Expand Down
2 changes: 1 addition & 1 deletion src/solvers/smt2/smt2_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class smt2_parsert
exprt let_expression();
exprt quantifier_expression(irep_idt);
exprt function_application(
const irep_idt &identifier,
const symbol_exprt &function,
const exprt::operandst &op);

/// Apply typecast to signedbv to expressions in vector
Expand Down