From a5c227778d7f0145434147830bd07a16f0f72134 Mon Sep 17 00:00:00 2001 From: chriseth Date: Sat, 31 Oct 2015 23:13:45 +0100 Subject: Bugfix: Returning literal strings in tuples. --- libsolidity/codegen/Compiler.cpp | 6 +++++- libsolidity/codegen/CompilerUtils.cpp | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'libsolidity/codegen') diff --git a/libsolidity/codegen/Compiler.cpp b/libsolidity/codegen/Compiler.cpp index 457b1e02..5daa37de 100644 --- a/libsolidity/codegen/Compiler.cpp +++ b/libsolidity/codegen/Compiler.cpp @@ -606,7 +606,11 @@ bool Compiler::visit(Return const& _return) for (auto const& retVariable: returnParameters) types.push_back(retVariable->annotation().type); - TypePointer expectedType = types.size() == 1 ? types.front() : make_shared(types); + TypePointer expectedType; + if (expression->annotation().type->category() == Type::Category::Tuple || types.size() != 1) + expectedType = make_shared(types); + else + expectedType = types.front(); compileExpression(*expression, expectedType); for (auto const& retVariable: boost::adaptors::reverse(returnParameters)) diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp index cd84f5fc..dd38ef97 100644 --- a/libsolidity/codegen/CompilerUtils.cpp +++ b/libsolidity/codegen/CompilerUtils.cpp @@ -598,7 +598,7 @@ void CompilerUtils::convertType(Type const& _typeOnStack, Type const& _targetTyp } // Value grew if (targetSize > sourceSize) - moveIntoStack(depth + targetSize - sourceSize, targetSize - sourceSize); + moveIntoStack(depth + targetSize - sourceSize - 1, targetSize - sourceSize); } } depth -= sourceSize; -- cgit