mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fix ICE on conditions with tuples of rationals
This commit is contained in:
parent
08a27b9c5b
commit
d3d77e482c
@ -8,6 +8,7 @@ Compiler Features:
|
|||||||
Bugfixes:
|
Bugfixes:
|
||||||
* SMTChecker: Fix lack of reporting potential violations when using only the CHC engine.
|
* SMTChecker: Fix lack of reporting potential violations when using only the CHC engine.
|
||||||
* SMTChecker: Fix internal error on conversion from string literal to byte.
|
* SMTChecker: Fix internal error on conversion from string literal to byte.
|
||||||
|
* SMTChecker: Fix internal error when using tuples of rational literals inside the conditional operator.
|
||||||
* Code generator: Fix missing creation dependency tracking for abstract contracts.
|
* Code generator: Fix missing creation dependency tracking for abstract contracts.
|
||||||
|
|
||||||
|
|
||||||
|
@ -574,8 +574,8 @@ bool SMTEncoder::visit(Conditional const& _op)
|
|||||||
|
|
||||||
defineExpr(_op, smtutil::Expression::ite(
|
defineExpr(_op, smtutil::Expression::ite(
|
||||||
expr(_op.condition()),
|
expr(_op.condition()),
|
||||||
expr(_op.trueExpression()),
|
expr(_op.trueExpression(), _op.annotation().type),
|
||||||
expr(_op.falseExpression())
|
expr(_op.falseExpression(), _op.annotation().type)
|
||||||
));
|
));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -245,7 +245,25 @@ SymbolicTupleVariable::SymbolicTupleVariable(
|
|||||||
solAssert(m_sort->kind == Kind::Tuple, "");
|
solAssert(m_sort->kind == Kind::Tuple, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<SortPointer> const& SymbolicTupleVariable::components()
|
smtutil::Expression SymbolicTupleVariable::currentValue(frontend::TypePointer const& _targetType) const
|
||||||
|
{
|
||||||
|
if (!_targetType || sort() == smtSort(*_targetType))
|
||||||
|
return SymbolicVariable::currentValue();
|
||||||
|
|
||||||
|
auto thisTuple = dynamic_pointer_cast<TupleSort>(sort());
|
||||||
|
auto otherTuple = dynamic_pointer_cast<TupleSort>(smtSort(*_targetType));
|
||||||
|
solAssert(thisTuple && otherTuple, "");
|
||||||
|
solAssert(thisTuple->components.size() == otherTuple->components.size(), "");
|
||||||
|
vector<smtutil::Expression> args;
|
||||||
|
for (size_t i = 0; i < thisTuple->components.size(); ++i)
|
||||||
|
args.emplace_back(component(i, type(), _targetType));
|
||||||
|
return smtutil::Expression::tuple_constructor(
|
||||||
|
smtutil::Expression(make_shared<smtutil::SortSort>(smtSort(*_targetType)), ""),
|
||||||
|
args
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<SortPointer> const& SymbolicTupleVariable::components() const
|
||||||
{
|
{
|
||||||
auto tupleSort = dynamic_pointer_cast<TupleSort>(m_sort);
|
auto tupleSort = dynamic_pointer_cast<TupleSort>(m_sort);
|
||||||
solAssert(tupleSort, "");
|
solAssert(tupleSort, "");
|
||||||
@ -256,7 +274,7 @@ smtutil::Expression SymbolicTupleVariable::component(
|
|||||||
size_t _index,
|
size_t _index,
|
||||||
TypePointer _fromType,
|
TypePointer _fromType,
|
||||||
TypePointer _toType
|
TypePointer _toType
|
||||||
)
|
) const
|
||||||
{
|
{
|
||||||
optional<smtutil::Expression> conversion = symbolicTypeConversion(_fromType, _toType);
|
optional<smtutil::Expression> conversion = symbolicTypeConversion(_fromType, _toType);
|
||||||
if (conversion)
|
if (conversion)
|
||||||
|
@ -225,12 +225,14 @@ public:
|
|||||||
EncodingContext& _context
|
EncodingContext& _context
|
||||||
);
|
);
|
||||||
|
|
||||||
std::vector<smtutil::SortPointer> const& components();
|
smtutil::Expression currentValue(frontend::TypePointer const& _targetType = TypePointer{}) const override;
|
||||||
|
|
||||||
|
std::vector<smtutil::SortPointer> const& components() const;
|
||||||
smtutil::Expression component(
|
smtutil::Expression component(
|
||||||
size_t _index,
|
size_t _index,
|
||||||
TypePointer _fromType = nullptr,
|
TypePointer _fromType = nullptr,
|
||||||
TypePointer _toType = nullptr
|
TypePointer _toType = nullptr
|
||||||
);
|
) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
pragma experimental SMTChecker;
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function f(bool x) public pure {
|
||||||
|
(uint a, uint b) = x ? (10000000001, 2) : (3, 4);
|
||||||
|
assert(a != 0);
|
||||||
|
assert(b != 0);
|
||||||
|
assert(a % 2 == 1);
|
||||||
|
assert(b % 2 == 0);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user