Support variable declarations without assignment in UnusedPruner

This commit is contained in:
Alex Beregszaszi 2018-02-06 09:53:49 +00:00
parent b0407cfac0
commit 2cbbe58281
2 changed files with 12 additions and 2 deletions

View File

@ -60,12 +60,14 @@ void UnusedPruner::operator()(Block& _block)
[=](TypedName const& _typedName) { return used(_typedName.name); }
))
{
if (!varDecl.value || MovableChecker(*varDecl.value).movable())
if (!varDecl.value)
statement = Block{std::move(varDecl.location), {}};
else if (MovableChecker(*varDecl.value).movable())
{
subtractReferences(ReferencesCounter::countReferences(*varDecl.value));
statement = Block{std::move(varDecl.location), {}};
}
else if (varDecl.value && varDecl.variables.size() == 1)
else if (varDecl.variables.size() == 1)
statement = ExpressionStatement{varDecl.location, FunctionalInstruction{
varDecl.location,
solidity::Instruction::POP,

View File

@ -63,6 +63,14 @@ BOOST_AUTO_TEST_CASE(trivial)
);
}
BOOST_AUTO_TEST_CASE(multi_declarations)
{
CHECK(
"{ let x, y }",
"{ }"
);
}
BOOST_AUTO_TEST_CASE(functions)
{
CHECK(