From 01d7d50750296422a093a7a8dc1d020b21f8f988 Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 11 Nov 2020 18:03:19 +0100 Subject: [PATCH] Fix initializing mapping return variables. --- libsolidity/codegen/ir/IRGeneratorForStatements.cpp | 4 +++- .../semanticTests/functionCall/mapping_internal_return.sol | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp index a24e3c0dd..7cee8dc53 100644 --- a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp +++ b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp @@ -208,7 +208,9 @@ void IRGeneratorForStatements::initializeLocalVar(VariableDeclaration const& _va solAssert(m_context.isLocalVariable(_varDecl), "Must be a local variable."); auto const* type = _varDecl.type(); - if (auto const* refType = dynamic_cast(type)) + if (dynamic_cast(type)) + return; + else if (auto const* refType = dynamic_cast(type)) if (refType->dataStoredIn(DataLocation::Storage) && refType->isPointer()) return; diff --git a/test/libsolidity/semanticTests/functionCall/mapping_internal_return.sol b/test/libsolidity/semanticTests/functionCall/mapping_internal_return.sol index 7756a92b1..b152298b9 100644 --- a/test/libsolidity/semanticTests/functionCall/mapping_internal_return.sol +++ b/test/libsolidity/semanticTests/functionCall/mapping_internal_return.sol @@ -17,6 +17,8 @@ contract test { return (a[0], a[1], a[2], b[0], b[1], b[2]); } } +// ==== +// compileViaYul: also // ---- // g() -> 0, 42, 0, 0, 84, 21 // h() -> 0, 42, 0, 0, 84, 17