Merge pull request #10991 from ethereum/bareCallNoReturndatacopy

[Sol->Yul] Fix bare call wihout returndatacopy.
This commit is contained in:
chriseth 2021-02-23 13:24:50 +01:00 committed by GitHub
commit d586b7b57a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 10 deletions

View File

@ -2521,9 +2521,7 @@ void IRGeneratorForStatements::appendBareCall(
</needsEncoding> </needsEncoding>
let <success> := <call>(<gas>, <address>, <?+value> <value>, </+value> <pos>, <length>, 0, 0) let <success> := <call>(<gas>, <address>, <?+value> <value>, </+value> <pos>, <length>, 0, 0)
<?+returndataVar> let <returndataVar> := <extractReturndataFunction>()
let <returndataVar> := <extractReturndataFunction>()
</+returndataVar>
)"); )");
templ("allocateUnbounded", m_utils.allocateUnboundedFunction()); templ("allocateUnbounded", m_utils.allocateUnboundedFunction());
@ -2542,13 +2540,8 @@ void IRGeneratorForStatements::appendBareCall(
} }
templ("success", IRVariable(_functionCall).tupleComponent(0).name()); templ("success", IRVariable(_functionCall).tupleComponent(0).name());
if (IRVariable(_functionCall).tupleComponent(1).type().category() == Type::Category::InaccessibleDynamic) templ("returndataVar", IRVariable(_functionCall).tupleComponent(1).commaSeparatedList());
templ("returndataVar", ""); templ("extractReturndataFunction", m_utils.extractReturndataFunction());
else
{
templ("returndataVar", IRVariable(_functionCall).tupleComponent(1).part("mpos").name());
templ("extractReturndataFunction", m_utils.extractReturndataFunction());
}
templ("address", IRVariable(_functionCall.expression()).part("address").name()); templ("address", IRVariable(_functionCall.expression()).part("address").name());

View File

@ -0,0 +1,10 @@
contract C {
function f() public returns (bool) {
(bool success, ) = address(1).call("");
return success;
}
}
// ====
// compileViaYul: also
// ----
// f() -> true