Fix assignment of return variables from modifiers.

This commit is contained in:
chriseth 2021-10-28 16:25:43 +02:00
parent 408bd5fa62
commit 8e208f23cb
3 changed files with 20 additions and 2 deletions

View File

@ -29,6 +29,9 @@ Bugfixes:
* Yul IR Generator: Do not output empty switches/if-bodies for empty contracts.
Important Bugfixes in Experimental Features:
* Yul IR Generator: Changes to function return variables referenced in modifier invocation arguments were not properly forwarded if there was more than one return variable.
### 0.8.9 (2021-09-29)

View File

@ -438,7 +438,7 @@ string IRGenerator::generateModifier(
for (size_t i = 0; i < retParamsIn.size(); ++i)
{
retParams.emplace_back(m_context.newYulVariable());
assignRetParams += retParams.back() + " := " + retParamsIn[i] + "\n";
assignRetParams += retParams.at(i) + " := " + retParamsIn.at(i) + "\n";
}
t("retParams", joinHumanReadable(retParams));
t("assignRetParams", assignRetParams);
@ -529,7 +529,7 @@ string IRGenerator::generateFunctionWithModifierInner(FunctionDefinition const&
for (size_t i = 0; i < retParams.size(); ++i)
{
retParamsIn.emplace_back(m_context.newYulVariable());
assignRetParams += retParams.back() + " := " + retParamsIn[i] + "\n";
assignRetParams += retParams.at(i) + " := " + retParamsIn.at(i) + "\n";
}
vector<string> params = retParamsIn;
for (auto const& varDecl: _function.parameters())

View File

@ -0,0 +1,15 @@
contract C {
modifier m1(uint value) {
_;
}
modifier m2(uint value) {
_;
}
function f() public m1(x = 2) m2(y = 3) returns (uint x, uint y) {
}
}
// ====
// compileViaYul: also
// ----
// f() -> 2, 3