diff options
author | Bob Summerwill <bob@summerwill.net> | 2016-04-16 02:26:46 +0800 |
---|---|---|
committer | Bob Summerwill <bob@summerwill.net> | 2016-04-16 02:26:46 +0800 |
commit | c9ed7facba3f8897cc43f170cee8c46442eca40d (patch) | |
tree | 1014242b5135b24cb87d2d6c1b006159e7437bca | |
parent | 5c3b41afb019a25a8e2784dbfa176a536d3eb03d (diff) | |
parent | b1250902088b04caccd25e24851350be36b2f819 (diff) | |
download | dexon-solidity-c9ed7facba3f8897cc43f170cee8c46442eca40d.tar dexon-solidity-c9ed7facba3f8897cc43f170cee8c46442eca40d.tar.gz dexon-solidity-c9ed7facba3f8897cc43f170cee8c46442eca40d.tar.bz2 dexon-solidity-c9ed7facba3f8897cc43f170cee8c46442eca40d.tar.lz dexon-solidity-c9ed7facba3f8897cc43f170cee8c46442eca40d.tar.xz dexon-solidity-c9ed7facba3f8897cc43f170cee8c46442eca40d.tar.zst dexon-solidity-c9ed7facba3f8897cc43f170cee8c46442eca40d.zip |
Merge pull request #506 from chriseth/fixconstructor
Bugfix for static arrays in constructor parameter list.
-rw-r--r-- | libsolidity/codegen/Compiler.cpp | 2 | ||||
-rw-r--r-- | test/libsolidity/SolidityEndToEndTest.cpp | 20 |
2 files changed, 21 insertions, 1 deletions
diff --git a/libsolidity/codegen/Compiler.cpp b/libsolidity/codegen/Compiler.cpp index 614c01ee..d4c94297 100644 --- a/libsolidity/codegen/Compiler.cpp +++ b/libsolidity/codegen/Compiler.cpp @@ -316,7 +316,7 @@ void Compiler::appendCalldataUnpacker(TypePointers const& _typeParameters, bool } else { - m_context << Instruction::DUP1; + m_context << Instruction::SWAP1 << Instruction::DUP2; m_context << u256(arrayType.calldataEncodedSize(true)) << Instruction::ADD; } } diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index a26570d3..f9d2ab2b 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -2000,6 +2000,26 @@ BOOST_AUTO_TEST_CASE(constructor_with_long_arguments) BOOST_CHECK(callContractFunction("b()") == encodeDyn(b)); } +BOOST_AUTO_TEST_CASE(constructor_static_array_argument) +{ + char const* sourceCode = R"( + contract C { + uint public a; + uint[3] public b; + + function C(uint _a, uint[3] _b) { + a = _a; + b = _b; + } + } + )"; + compileAndRun(sourceCode, 0, "C", encodeArgs(u256(1), u256(2), u256(3), u256(4))); + BOOST_CHECK(callContractFunction("a()") == encodeArgs(u256(1))); + BOOST_CHECK(callContractFunction("b(uint256)", u256(0)) == encodeArgs(u256(2))); + BOOST_CHECK(callContractFunction("b(uint256)", u256(1)) == encodeArgs(u256(3))); + BOOST_CHECK(callContractFunction("b(uint256)", u256(2)) == encodeArgs(u256(4))); +} + BOOST_AUTO_TEST_CASE(functions_called_by_constructor) { char const* sourceCode = R"( |