Skip to content

Commit 6b38c64

Browse files
author
Leonardo
authored
Merge pull request ethereum#9709 from ethereum/smt_fix_tuple_3
[SMTChecker] Fix ICE on tuples of one element of tuple type
2 parents 20b359e + 238b8a9 commit 6b38c64

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Bugfixes:
2222
* SMTChecker: Fix internal error on fixed bytes index access.
2323
* SMTChecker: Fix internal error on lvalue unary operators with tuples.
2424
* SMTChecker: Fix internal error on tuple assignment.
25+
* SMTChecker: Fix internal error on tuples of one element that have tuple type.
2526
* SMTChecker: Fix soundness of array ``pop``.
2627
* References Resolver: Fix internal bug when using constructor for library.
2728
* Yul Optimizer: Make function inlining order more resilient to whether or not unrelated source files are present.

libsolidity/formal/SMTEncoder.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -420,8 +420,11 @@ void SMTEncoder::endVisit(TupleExpression const& _tuple)
420420
_tuple.location(),
421421
"Assertion checker does not yet implement inline arrays."
422422
);
423-
else if (_tuple.annotation().type->category() == Type::Category::Tuple)
423+
else if (_tuple.components().size() == 1)
424+
defineExpr(_tuple, expr(*_tuple.components().front()));
425+
else
424426
{
427+
solAssert(_tuple.annotation().type->category() == Type::Category::Tuple, "");
425428
auto const& symbTuple = dynamic_pointer_cast<smt::SymbolicTupleVariable>(m_context.expression(_tuple));
426429
solAssert(symbTuple, "");
427430
auto const& symbComponents = symbTuple->components();
@@ -445,13 +448,6 @@ void SMTEncoder::endVisit(TupleExpression const& _tuple)
445448
}
446449
}
447450
}
448-
else
449-
{
450-
/// Parenthesized expressions are also TupleExpression regardless their type.
451-
auto const& components = _tuple.components();
452-
solAssert(components.size() == 1, "");
453-
defineExpr(_tuple, expr(*components.front()));
454-
}
455451
}
456452

457453
void SMTEncoder::endVisit(UnaryOperation const& _op)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
pragma experimental SMTChecker;
2+
contract C {
3+
function g() internal pure returns (uint, uint) {
4+
return (2, 3);
5+
}
6+
function f() public {
7+
(address(1).call(""));
8+
(uint x, uint y) = ((g()));
9+
assert(x == 2);
10+
assert(y == 3);
11+
}
12+
}
13+
// ----
14+
// Warning 5084: (142-152): Type conversion is not yet fully supported and might yield false positives.

0 commit comments

Comments
 (0)