Skip to content

Commit

Permalink
Fix boolean constants.
Browse files Browse the repository at this point in the history
  • Loading branch information
chriseth authored and axic committed Nov 22, 2017
1 parent 90fb14f commit 95a65dc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
9 changes: 7 additions & 2 deletions libsolidity/formal/Z3Interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,13 @@ z3::expr Z3Interface::toZ3Expr(Expression const& _expr)
}
else if (arguments.empty())
{
// We assume it is an integer...
return m_context.int_val(n.c_str());
if (n == "true")
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(), "");
Expand Down
21 changes: 9 additions & 12 deletions test/libsolidity/SMTChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,18 +362,15 @@ BOOST_AUTO_TEST_CASE(constant_condition)
}
)";
CHECK_WARNING(text, "Condition is always false");
// TODO
// // a plain literal constant is fine
// text = R"(
// contract C {
// function f(uint x) public pure {
// if (true) { revert(); }
// }
// }
// )";
// CHECK_SUCCESS_NO_WARNINGS(text);

// TODO test unreacheable code
// a plain literal constant is fine
text = R"(
contract C {
function f(uint) public pure {
if (true) { revert(); }
}
}
)";
CHECK_SUCCESS_NO_WARNINGS(text);
}

BOOST_AUTO_TEST_SUITE_END()
Expand Down

0 comments on commit 95a65dc

Please sign in to comment.