From fe5f85ef344dff2ecefb7ac3782221f9cf5effc1 Mon Sep 17 00:00:00 2001 From: chriseth Date: Mon, 6 Mar 2017 14:42:16 +0100 Subject: Test for array singletons. --- test/libsolidity/SolidityEndToEndTest.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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"( -- cgit From c500d9f717d50137be7d9507dfc4abf0840caf48 Mon Sep 17 00:00:00 2001 From: chriseth Date: Mon, 6 Mar 2017 14:38:29 +0100 Subject: Convert to mobile type for array type. --- libsolidity/analysis/TypeChecker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 5426cd17..54139546 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -1014,7 +1014,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]); } -- cgit