mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[SMTChecker] Support tuples with multiple var decls
This commit is contained in:
parent
133fd18223
commit
3c7540ceb2
@ -6,7 +6,7 @@ Language Features:
|
|||||||
|
|
||||||
Compiler Features:
|
Compiler Features:
|
||||||
* SMTChecker: Support inherited state variables.
|
* SMTChecker: Support inherited state variables.
|
||||||
* SMTChecker: Support tuple assignments and function calls with multiple return values.
|
* SMTChecker: Support tuples and function calls with multiple return values.
|
||||||
* SMTChecker: Support ``delete``.
|
* SMTChecker: Support ``delete``.
|
||||||
|
|
||||||
|
|
||||||
|
@ -330,20 +330,35 @@ bool SMTChecker::visit(ForStatement const& _node)
|
|||||||
void SMTChecker::endVisit(VariableDeclarationStatement const& _varDecl)
|
void SMTChecker::endVisit(VariableDeclarationStatement const& _varDecl)
|
||||||
{
|
{
|
||||||
if (_varDecl.declarations().size() != 1)
|
if (_varDecl.declarations().size() != 1)
|
||||||
m_errorReporter.warning(
|
{
|
||||||
_varDecl.location(),
|
if (auto init = _varDecl.initialValue())
|
||||||
"Assertion checker does not yet support such variable declarations."
|
{
|
||||||
);
|
auto symbTuple = dynamic_pointer_cast<SymbolicTupleVariable>(m_expressions[init]);
|
||||||
else if (knownVariable(*_varDecl.declarations()[0]))
|
/// symbTuple == nullptr if it is the return of a non-inlined function call.
|
||||||
|
if (symbTuple)
|
||||||
|
{
|
||||||
|
auto const& components = symbTuple->components();
|
||||||
|
auto const& declarations = _varDecl.declarations();
|
||||||
|
for (unsigned i = 0; i < declarations.size(); ++i)
|
||||||
|
{
|
||||||
|
solAssert(components.at(i), "");
|
||||||
|
if (declarations.at(i) && knownVariable(*declarations.at(i)))
|
||||||
|
assignment(*declarations.at(i), components.at(i)->currentValue(), declarations.at(i)->location());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (knownVariable(*_varDecl.declarations().front()))
|
||||||
{
|
{
|
||||||
if (_varDecl.initialValue())
|
if (_varDecl.initialValue())
|
||||||
assignment(*_varDecl.declarations()[0], *_varDecl.initialValue(), _varDecl.location());
|
assignment(*_varDecl.declarations().front(), *_varDecl.initialValue(), _varDecl.location());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_errorReporter.warning(
|
m_errorReporter.warning(
|
||||||
_varDecl.location(),
|
_varDecl.location(),
|
||||||
"Assertion checker does not yet implement such variable declarations."
|
"Assertion checker does not yet implement such variable declarations."
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SMTChecker::endVisit(Assignment const& _assignment)
|
void SMTChecker::endVisit(Assignment const& _assignment)
|
||||||
|
@ -19,5 +19,4 @@ contract C
|
|||||||
// EVMVersion: >spuriousDragon
|
// EVMVersion: >spuriousDragon
|
||||||
// ----
|
// ----
|
||||||
// Warning: (224-240): Unused local variable.
|
// Warning: (224-240): Unused local variable.
|
||||||
// Warning: (209-256): Assertion checker does not yet support such variable declarations.
|
|
||||||
// Warning: (260-275): Assertion violation happens here
|
// Warning: (260-275): Assertion violation happens here
|
||||||
|
@ -19,5 +19,4 @@ contract C
|
|||||||
// EVMVersion: >spuriousDragon
|
// EVMVersion: >spuriousDragon
|
||||||
// ----
|
// ----
|
||||||
// Warning: (224-240): Unused local variable.
|
// Warning: (224-240): Unused local variable.
|
||||||
// Warning: (209-264): Assertion checker does not yet support such variable declarations.
|
|
||||||
// Warning: (268-283): Assertion violation happens here
|
// Warning: (268-283): Assertion violation happens here
|
||||||
|
@ -19,5 +19,4 @@ contract C
|
|||||||
// EVMVersion: >spuriousDragon
|
// EVMVersion: >spuriousDragon
|
||||||
// ----
|
// ----
|
||||||
// Warning: (224-240): Unused local variable.
|
// Warning: (224-240): Unused local variable.
|
||||||
// Warning: (209-262): Assertion checker does not yet support such variable declarations.
|
|
||||||
// Warning: (266-281): Assertion violation happens here
|
// Warning: (266-281): Assertion violation happens here
|
||||||
|
@ -9,5 +9,3 @@ contract C
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// Warning: (76-101): Assertion checker does not yet support such variable declarations.
|
|
||||||
// Warning: (105-119): Assertion violation happens here
|
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
pragma experimental SMTChecker;
|
||||||
|
|
||||||
|
contract C
|
||||||
|
{
|
||||||
|
function g() public pure {
|
||||||
|
(uint x, ) = (2, 4);
|
||||||
|
assert(x == 2);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
pragma experimental SMTChecker;
|
||||||
|
|
||||||
|
contract C
|
||||||
|
{
|
||||||
|
function f() internal pure returns (uint, bool, uint) {
|
||||||
|
uint x = 3;
|
||||||
|
bool b = true;
|
||||||
|
uint y = 999;
|
||||||
|
return (x, b, y);
|
||||||
|
}
|
||||||
|
function g() public pure {
|
||||||
|
(uint x, bool b, uint y) = f();
|
||||||
|
assert(x == 3);
|
||||||
|
assert(b);
|
||||||
|
assert(y == 999);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
pragma experimental SMTChecker;
|
||||||
|
|
||||||
|
contract C
|
||||||
|
{
|
||||||
|
function f(uint x) internal pure returns (uint, bool, uint) {
|
||||||
|
bool b = true;
|
||||||
|
uint y = 999;
|
||||||
|
return (x * 2, b, y);
|
||||||
|
}
|
||||||
|
function g() public pure {
|
||||||
|
(uint x, bool b, uint y) = f(7);
|
||||||
|
assert(x == 14);
|
||||||
|
assert(b);
|
||||||
|
assert(y == 999);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// Warning: (152-157): Overflow (resulting value larger than 2**256 - 1) happens here
|
@ -0,0 +1,17 @@
|
|||||||
|
pragma experimental SMTChecker;
|
||||||
|
|
||||||
|
contract C
|
||||||
|
{
|
||||||
|
function f() internal pure returns (uint, bool, uint) {
|
||||||
|
uint x = 3;
|
||||||
|
bool b = true;
|
||||||
|
uint y = 999;
|
||||||
|
return (x, b, y);
|
||||||
|
}
|
||||||
|
function g() public pure {
|
||||||
|
(, bool b,) = f();
|
||||||
|
assert(!b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// Warning: (224-234): Assertion violation happens here
|
Loading…
Reference in New Issue
Block a user