mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Test for self-referring assignment.
This commit is contained in:
parent
669b63ca5f
commit
c0abddc9dc
@ -135,9 +135,7 @@ void DataFlowAnalyzer::handleAssignment(set<string> const& _variables, Expressio
|
|||||||
string const& name = *_variables.begin();
|
string const& name = *_variables.begin();
|
||||||
// Expression has to be movable and cannot contain a reference
|
// Expression has to be movable and cannot contain a reference
|
||||||
// to the variable that will be assigned to.
|
// to the variable that will be assigned to.
|
||||||
// TODO: Add a test for that
|
|
||||||
if (_value && movableChecker.movable() && !movableChecker.referencedVariables().count(name))
|
if (_value && movableChecker.movable() && !movableChecker.referencedVariables().count(name))
|
||||||
// TODO If _value is null, we could use zero.
|
|
||||||
m_value[name] = _value;
|
m_value[name] = _value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,6 +146,15 @@ BOOST_AUTO_TEST_CASE(reassignment)
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(update_assignment_remat)
|
||||||
|
{
|
||||||
|
// We cannot substitute `a` in `let b := a`
|
||||||
|
CHECK(
|
||||||
|
"{ let a := extcodesize(0) a := mul(a, 2) let b := a }",
|
||||||
|
"{ let a := extcodesize(0) a := mul(a, 2) let b := a }"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(do_not_move_out_of_scope)
|
BOOST_AUTO_TEST_CASE(do_not_move_out_of_scope)
|
||||||
{
|
{
|
||||||
// Cannot replace by `let b := x` by `let b := a` since a is out of scope.
|
// Cannot replace by `let b := x` by `let b := a` since a is out of scope.
|
||||||
|
Loading…
Reference in New Issue
Block a user