Merge pull request #10910 from ethereum/calldataLValueSol2Yul

[Sol->Yul] Fixing setLValue for calldata types.
This commit is contained in:
chriseth 2021-02-08 13:17:58 +01:00 committed by GitHub
commit 711671236a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View File

@ -2918,10 +2918,7 @@ void IRGeneratorForStatements::setLValue(Expression const& _expression, IRLValue
solAssert(!m_currentLValue, "");
if (_expression.annotation().willBeWrittenTo)
{
m_currentLValue.emplace(std::move(_lvalue));
solAssert(!_lvalue.type.dataStoredIn(DataLocation::CallData), "");
}
else
// Only define the expression, if it will not be written to.
define(_expression, readFromLValue(_lvalue));

View File

@ -0,0 +1,10 @@
contract C {
function f(uint256[] calldata x, uint256[] calldata y, uint256 i) external returns (uint256) {
x = y;
return x[i];
}
}
// ====
// compileViaYul: also
// ----
// f(uint256[], uint256[], uint256): 0x60, 0xA0, 1, 1, 0, 2, 1, 2 -> 2