aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-02-06 19:58:51 +0800
committerchriseth <chris@ethereum.org>2018-02-06 19:58:51 +0800
commitc0abddc9dcbf1f0437ac04119a0c8c238fad44c8 (patch)
tree83a1ce096f9cac08e40c96cef5af222b74c9b8bf
parent669b63ca5fd612cabc28ddb9fb8c58ab60b2c75a (diff)
downloaddexon-solidity-c0abddc9dcbf1f0437ac04119a0c8c238fad44c8.tar.gz
dexon-solidity-c0abddc9dcbf1f0437ac04119a0c8c238fad44c8.tar.zst
dexon-solidity-c0abddc9dcbf1f0437ac04119a0c8c238fad44c8.zip
Test for self-referring assignment.
-rw-r--r--libjulia/optimiser/DataFlowAnalyzer.cpp2
-rw-r--r--test/libjulia/Rematerialiser.cpp9
2 files changed, 9 insertions, 2 deletions
diff --git a/libjulia/optimiser/DataFlowAnalyzer.cpp b/libjulia/optimiser/DataFlowAnalyzer.cpp
index 9ee3215d..56653393 100644
--- a/libjulia/optimiser/DataFlowAnalyzer.cpp
+++ b/libjulia/optimiser/DataFlowAnalyzer.cpp
@@ -135,9 +135,7 @@ void DataFlowAnalyzer::handleAssignment(set<string> const& _variables, Expressio
string const& name = *_variables.begin();
// Expression has to be movable and cannot contain a reference
// to the variable that will be assigned to.
- // TODO: Add a test for that
if (_value && movableChecker.movable() && !movableChecker.referencedVariables().count(name))
- // TODO If _value is null, we could use zero.
m_value[name] = _value;
}
diff --git a/test/libjulia/Rematerialiser.cpp b/test/libjulia/Rematerialiser.cpp
index 5bd69236..8f928f8e 100644
--- a/test/libjulia/Rematerialiser.cpp
+++ b/test/libjulia/Rematerialiser.cpp
@@ -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)
{
// Cannot replace by `let b := x` by `let b := a` since a is out of scope.