mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #8672 from ethereum/fixYulEmptyTupleAssign
Fix tuple assignments for empty tuples in Yul IR.
This commit is contained in:
commit
95349b3634
@ -2079,7 +2079,7 @@ string YulUtilFunctions::conversionFunctionSpecial(Type const& _from, Type const
|
|||||||
{
|
{
|
||||||
conversions +=
|
conversions +=
|
||||||
suffixedVariableNameList("converted", destStackSize, destStackSize + toComponent->sizeOnStack()) +
|
suffixedVariableNameList("converted", destStackSize, destStackSize + toComponent->sizeOnStack()) +
|
||||||
" := " +
|
(toComponent->sizeOnStack() > 0 ? " := " : "") +
|
||||||
conversionFunction(*fromComponent, *toComponent) +
|
conversionFunction(*fromComponent, *toComponent) +
|
||||||
"(" +
|
"(" +
|
||||||
suffixedVariableNameList("value", sourceStackSize, sourceStackSize + fromComponent->sizeOnStack()) +
|
suffixedVariableNameList("value", sourceStackSize, sourceStackSize + fromComponent->sizeOnStack()) +
|
||||||
@ -2089,12 +2089,13 @@ string YulUtilFunctions::conversionFunctionSpecial(Type const& _from, Type const
|
|||||||
sourceStackSize += fromComponent->sizeOnStack();
|
sourceStackSize += fromComponent->sizeOnStack();
|
||||||
}
|
}
|
||||||
return Whiskers(R"(
|
return Whiskers(R"(
|
||||||
function <functionName>(<values>) -> <converted> {
|
function <functionName>(<values>) <arrow> <converted> {
|
||||||
<conversions>
|
<conversions>
|
||||||
}
|
}
|
||||||
)")
|
)")
|
||||||
("functionName", functionName)
|
("functionName", functionName)
|
||||||
("values", suffixedVariableNameList("value", 0, sourceStackSize))
|
("values", suffixedVariableNameList("value", 0, sourceStackSize))
|
||||||
|
("arrow", destStackSize > 0 ? "->" : "")
|
||||||
("converted", suffixedVariableNameList("converted", 0, destStackSize))
|
("converted", suffixedVariableNameList("converted", 0, destStackSize))
|
||||||
("conversions", conversions)
|
("conversions", conversions)
|
||||||
.render();
|
.render();
|
||||||
|
@ -1465,14 +1465,17 @@ void IRGeneratorForStatements::declareAssign(IRVariable const& _lhs, IRVariable
|
|||||||
else
|
else
|
||||||
m_code << (_declare ? "let ": "") << _lhs.part(stackItemName).name() << " := " << _rhs.part(stackItemName).name() << "\n";
|
m_code << (_declare ? "let ": "") << _lhs.part(stackItemName).name() << " := " << _rhs.part(stackItemName).name() << "\n";
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (_lhs.type().sizeOnStack() > 0)
|
||||||
m_code <<
|
m_code <<
|
||||||
(_declare ? "let ": "") <<
|
(_declare ? "let ": "") <<
|
||||||
_lhs.commaSeparatedList() <<
|
_lhs.commaSeparatedList() <<
|
||||||
" := " <<
|
" := ";
|
||||||
m_context.utils().conversionFunction(_rhs.type(), _lhs.type()) <<
|
m_code << m_context.utils().conversionFunction(_rhs.type(), _lhs.type()) <<
|
||||||
"(" <<
|
"(" <<
|
||||||
_rhs.commaSeparatedList() <<
|
_rhs.commaSeparatedList() <<
|
||||||
")\n";
|
")\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IRVariable IRGeneratorForStatements::zeroValue(Type const& _type, bool _splitFunctionTypes)
|
IRVariable IRGeneratorForStatements::zeroValue(Type const& _type, bool _splitFunctionTypes)
|
||||||
|
@ -15,6 +15,16 @@ contract test {
|
|||||||
(((, a),)) = ((1, 2), 3);
|
(((, a),)) = ((1, 2), 3);
|
||||||
return a;
|
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
|
// compileViaYul: also
|
||||||
@ -22,3 +32,5 @@ contract test {
|
|||||||
// f0() -> 2, true
|
// f0() -> 2, true
|
||||||
// f1() -> 1
|
// f1() -> 1
|
||||||
// f2() -> 2
|
// f2() -> 2
|
||||||
|
// f3() -> 3
|
||||||
|
// f4() -> 4
|
||||||
|
@ -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
|
|
Loading…
Reference in New Issue
Block a user