diff --git a/libsolidity/codegen/YulUtilFunctions.cpp b/libsolidity/codegen/YulUtilFunctions.cpp index 2f14ae744..e520c586f 100644 --- a/libsolidity/codegen/YulUtilFunctions.cpp +++ b/libsolidity/codegen/YulUtilFunctions.cpp @@ -2079,7 +2079,7 @@ string YulUtilFunctions::conversionFunctionSpecial(Type const& _from, Type const { conversions += suffixedVariableNameList("converted", destStackSize, destStackSize + toComponent->sizeOnStack()) + - " := " + + (toComponent->sizeOnStack() > 0 ? " := " : "") + conversionFunction(*fromComponent, *toComponent) + "(" + suffixedVariableNameList("value", sourceStackSize, sourceStackSize + fromComponent->sizeOnStack()) + @@ -2089,12 +2089,13 @@ string YulUtilFunctions::conversionFunctionSpecial(Type const& _from, Type const sourceStackSize += fromComponent->sizeOnStack(); } return Whiskers(R"( - function () -> { + function () { } )") ("functionName", functionName) ("values", suffixedVariableNameList("value", 0, sourceStackSize)) + ("arrow", destStackSize > 0 ? "->" : "") ("converted", suffixedVariableNameList("converted", 0, destStackSize)) ("conversions", conversions) .render(); diff --git a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp index a6858d854..5046925fd 100644 --- a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp +++ b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp @@ -1465,14 +1465,17 @@ void IRGeneratorForStatements::declareAssign(IRVariable const& _lhs, IRVariable else m_code << (_declare ? "let ": "") << _lhs.part(stackItemName).name() << " := " << _rhs.part(stackItemName).name() << "\n"; else - m_code << - (_declare ? "let ": "") << - _lhs.commaSeparatedList() << - " := " << - m_context.utils().conversionFunction(_rhs.type(), _lhs.type()) << + { + if (_lhs.type().sizeOnStack() > 0) + m_code << + (_declare ? "let ": "") << + _lhs.commaSeparatedList() << + " := "; + m_code << m_context.utils().conversionFunction(_rhs.type(), _lhs.type()) << "(" << _rhs.commaSeparatedList() << ")\n"; + } } IRVariable IRGeneratorForStatements::zeroValue(Type const& _type, bool _splitFunctionTypes) diff --git a/test/libsolidity/semanticTests/types/nested_tuples.sol b/test/libsolidity/semanticTests/types/nested_tuples.sol index d9737a807..b94d44370 100644 --- a/test/libsolidity/semanticTests/types/nested_tuples.sol +++ b/test/libsolidity/semanticTests/types/nested_tuples.sol @@ -15,6 +15,16 @@ contract test { (((, a),)) = ((1, 2), 3); return a; } + function f3() public returns(int) { + int a = 3; + ((, ), ) = ((7, 8), 9); + return a; + } + function f4() public returns(int) { + int a; + (a, ) = (4, (8, 16, 32)); + return a; + } } // ==== // compileViaYul: also @@ -22,3 +32,5 @@ contract test { // f0() -> 2, true // f1() -> 1 // f2() -> 2 +// f3() -> 3 +// f4() -> 4 diff --git a/test/libsolidity/semanticTests/types/nested_tuples_noyul.sol b/test/libsolidity/semanticTests/types/nested_tuples_noyul.sol deleted file mode 100644 index 1eff9e2b9..000000000 --- a/test/libsolidity/semanticTests/types/nested_tuples_noyul.sol +++ /dev/null @@ -1,17 +0,0 @@ -contract test { - function f3() public returns(int) { - int a = 3; - ((, ), ) = ((7, 8), 9); - return a; - } - function f4() public returns(int) { - int a; - (a, ) = (4, (8, 16, 32)); - return a; - } -} -// ==== -// compileViaYul: false -// ---- -// f3() -> 3 -// f4() -> 4