diff options
author | chriseth <chris@ethereum.org> | 2017-03-08 23:11:03 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-08 23:11:03 +0800 |
commit | 3f9a7758348a30c4c65a99054e1e1055d1bb20c0 (patch) | |
tree | 12aa5b312a55e1c6d41e1db70cf0969b6d75aac1 | |
parent | 69a06fe1633c3e5204e6ae4276dd985eae29acfe (diff) | |
parent | c500d9f717d50137be7d9507dfc4abf0840caf48 (diff) | |
download | dexon-solidity-3f9a7758348a30c4c65a99054e1e1055d1bb20c0.tar dexon-solidity-3f9a7758348a30c4c65a99054e1e1055d1bb20c0.tar.gz dexon-solidity-3f9a7758348a30c4c65a99054e1e1055d1bb20c0.tar.bz2 dexon-solidity-3f9a7758348a30c4c65a99054e1e1055d1bb20c0.tar.lz dexon-solidity-3f9a7758348a30c4c65a99054e1e1055d1bb20c0.tar.xz dexon-solidity-3f9a7758348a30c4c65a99054e1e1055d1bb20c0.tar.zst dexon-solidity-3f9a7758348a30c4c65a99054e1e1055d1bb20c0.zip |
Merge pull request #1748 from ethereum/singletonArray
Use mobile type for singleton array.
-rw-r--r-- | libsolidity/analysis/TypeChecker.cpp | 2 | ||||
-rw-r--r-- | test/libsolidity/SolidityEndToEndTest.cpp | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index acceffda..ad1abcfb 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -1029,7 +1029,7 @@ bool TypeChecker::visit(TupleExpression const& _tuple) fatalTypeError(components[i]->location(), "Invalid mobile type."); if (i == 0) - inlineArrayType = types[i]; + inlineArrayType = types[i]->mobileType(); else if (inlineArrayType) inlineArrayType = Type::commonType(inlineArrayType, types[i]); } diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 130b0d3a..baed3f1e 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -7260,6 +7260,20 @@ BOOST_AUTO_TEST_CASE(inline_array_return) BOOST_CHECK(callContractFunction("f()") == encodeArgs(1, 2, 3, 4, 5)); } +BOOST_AUTO_TEST_CASE(inline_array_singleton) +{ + // This caused a failure since the type was not converted to its mobile type. + char const* sourceCode = R"( + contract C { + function f() returns (uint) { + return [4][0]; + } + } + )"; + compileAndRun(sourceCode, 0, "C"); + BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(4))); +} + BOOST_AUTO_TEST_CASE(inline_long_string_return) { char const* sourceCode = R"( |