diff --git a/libsolidity/SolidityABIJSON.cpp b/libsolidity/SolidityABIJSON.cpp index f0e54a940..26d0110b8 100644 --- a/libsolidity/SolidityABIJSON.cpp +++ b/libsolidity/SolidityABIJSON.cpp @@ -495,6 +495,36 @@ BOOST_AUTO_TEST_CASE(empty_name_return_parameter) checkInterface(sourceCode, interface); } +BOOST_AUTO_TEST_CASE(constructor_abi) +{ + char const* sourceCode = R"( + contract test { + function test(uint param1, test param2, bool param3) {} + } + )"; + + char const* interface = R"([ + { + "inputs": [ + { + "name": "param1", + "type": "uint256" + }, + { + "name": "param2", + "type": "address" + }, + { + "name": "param3", + "type": "bool" + } + ], + "type": "constructor" + } + ])"; + checkInterface(sourceCode, interface); +} + BOOST_AUTO_TEST_SUITE_END() } diff --git a/libsolidity/SolidityOptimizer.cpp b/libsolidity/SolidityOptimizer.cpp index af9b51467..ceb9c68d9 100644 --- a/libsolidity/SolidityOptimizer.cpp +++ b/libsolidity/SolidityOptimizer.cpp @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -84,9 +85,20 @@ public: AssemblyItems getCSE(AssemblyItems const& _input) { + // add dummy locations to each item so that we can check that they are not deleted + AssemblyItems input = _input; + for (AssemblyItem& item: input) + item.setLocation(SourceLocation(1, 3, make_shared(""))); + eth::CommonSubexpressionEliminator cse; - BOOST_REQUIRE(cse.feedItems(_input.begin(), _input.end()) == _input.end()); - return cse.getOptimizedItems(); + BOOST_REQUIRE(cse.feedItems(input.begin(), input.end()) == input.end()); + AssemblyItems output = cse.getOptimizedItems(); + + for (AssemblyItem const& item: output) + { + BOOST_CHECK(item == Instruction::POP || !item.getLocation().isEmpty()); + } + return output; } void checkCSE(AssemblyItems const& _input, AssemblyItems const& _expectation)