aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-02-26 18:13:21 +0800
committerchriseth <chris@ethereum.org>2018-02-26 18:17:32 +0800
commit8ae6a76c58c7c35f429379fb67ccdfb457fc8e91 (patch)
tree0a8bd8a674afaf14e9d49cb8f0b9a2b6d59fa756
parent917dd28eef06dd62498073fc24f8a7beb6d9c553 (diff)
downloaddexon-solidity-8ae6a76c58c7c35f429379fb67ccdfb457fc8e91.tar.gz
dexon-solidity-8ae6a76c58c7c35f429379fb67ccdfb457fc8e91.tar.zst
dexon-solidity-8ae6a76c58c7c35f429379fb67ccdfb457fc8e91.zip
Test data location of getter return type.
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index 27761066..93abee0d 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -7841,6 +7841,26 @@ BOOST_AUTO_TEST_CASE(old_style_events_050)
CHECK_ERROR(text, TypeError, "have to be prefixed");
}
+BOOST_AUTO_TEST_CASE(getter_is_memory_type)
+{
+ char const* text = R"(
+ contract C {
+ struct S { string m; }
+ string[] public x;
+ S[] public y;
+ }
+ )";
+ CHECK_SUCCESS_NO_WARNINGS(text);
+ // Check that the getters return a memory strings, not a storage strings.
+ ContractDefinition const& c = dynamic_cast<ContractDefinition const&>(*m_compiler.ast("").nodes().at(1));
+ BOOST_CHECK(c.interfaceFunctions().size() == 2);
+ for (auto const& f: c.interfaceFunctions())
+ {
+ auto const& retType = f.second->returnParameterTypes().at(0);
+ BOOST_CHECK(retType->dataStoredIn(DataLocation::Memory));
+ }
+}
+
BOOST_AUTO_TEST_SUITE_END()
}