Fix boolean constants.

This commit is contained in:
chriseth 2017-10-04 18:20:56 +02:00 committed by Alex Beregszaszi
parent 90fb14f525
commit 95a65dc04c
2 changed files with 16 additions and 14 deletions

View File

@ -139,8 +139,13 @@ z3::expr Z3Interface::toZ3Expr(Expression const& _expr)
} }
else if (arguments.empty()) else if (arguments.empty())
{ {
// We assume it is an integer... if (n == "true")
return m_context.int_val(n.c_str()); return m_context.bool_val(true);
else if (n == "false")
return m_context.bool_val(false);
else
// We assume it is an integer...
return m_context.int_val(n.c_str());
} }
solAssert(arity.count(n) && arity.at(n) == arguments.size(), ""); solAssert(arity.count(n) && arity.at(n) == arguments.size(), "");

View File

@ -362,18 +362,15 @@ BOOST_AUTO_TEST_CASE(constant_condition)
} }
)"; )";
CHECK_WARNING(text, "Condition is always false"); CHECK_WARNING(text, "Condition is always false");
// TODO // a plain literal constant is fine
// // a plain literal constant is fine text = R"(
// text = R"( contract C {
// contract C { function f(uint) public pure {
// function f(uint x) public pure { if (true) { revert(); }
// if (true) { revert(); } }
// } }
// } )";
// )"; CHECK_SUCCESS_NO_WARNINGS(text);
// CHECK_SUCCESS_NO_WARNINGS(text);
// TODO test unreacheable code
} }
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()