diff --git a/Changelog.md b/Changelog.md index 3fa7c9dec99a..bbb59751ccc1 100644 --- a/Changelog.md +++ b/Changelog.md @@ -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. diff --git a/libsolidity/codegen/ABIFunctions.cpp b/libsolidity/codegen/ABIFunctions.cpp index 653451a6fc6e..f4c743174fa1 100644 --- a/libsolidity/codegen/ABIFunctions.cpp +++ b/libsolidity/codegen/ABIFunctions.cpp @@ -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; diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index a7ff7a89cb3a..c8fbbff7b8a7 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -9037,9 +9037,13 @@ BOOST_AUTO_TEST_CASE(using_library_mappings_external) } } )"; - compileAndRun(libSourceCode, 0, "Lib"); - compileAndRun(sourceCode, 0, "Test", bytes(), map{{"Lib", m_contractAddress}}); - ABI_CHECK(callContractFunction("f()"), encodeArgs(u256(2), u256(0), u256(84), u256(46), u256(0), u256(198))); + for (auto v2: {false, true}) + { + string prefix = v2 ? "pragma experimental ABIEncoderV2;\n" : ""; + compileAndRun(prefix + libSourceCode, 0, "Lib"); + compileAndRun(prefix + sourceCode, 0, "Test", bytes(), map{{"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)