Allow cleanup for mappings (do nothing).

This commit is contained in:
chriseth 2019-02-18 18:48:35 +01:00
parent 1b6d87c5bd
commit c690f679cb
3 changed files with 9 additions and 3 deletions

View File

@ -7,6 +7,7 @@ Compiler Features:
Bugfixes:
* ABIEncoderV2: Fix internal error related to mappings as library parameters.
* Yul: Properly detect name clashes with functions before their declaration.

View File

@ -308,6 +308,7 @@ string ABIFunctions::cleanupFunction(Type const& _type, bool _revertOnFailure)
break;
case Type::Category::Array:
case Type::Category::Struct:
case Type::Category::Mapping:
solAssert(_type.dataStoredIn(DataLocation::Storage), "Cleanup requested for non-storage reference type.");
templ("body", "cleaned := value");
break;

View File

@ -9037,9 +9037,13 @@ BOOST_AUTO_TEST_CASE(using_library_mappings_external)
}
}
)";
compileAndRun(libSourceCode, 0, "Lib");
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, Address>{{"Lib", m_contractAddress}});
for (auto v2: {false, true})
{
string prefix = v2 ? "pragma experimental ABIEncoderV2;\n" : "";
compileAndRun(prefix + libSourceCode, 0, "Lib");
compileAndRun(prefix + sourceCode, 0, "Test", bytes(), map<string, Address>{{"Lib", m_contractAddress}});
ABI_CHECK(callContractFunction("f()"), encodeArgs(u256(2), u256(0), u256(84), u256(46), u256(0), u256(198)));
}
}
BOOST_AUTO_TEST_CASE(using_library_mappings_return)