mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fix abi encode with signature shortcut.
This commit is contained in:
parent
6ac87a144e
commit
4f3839e4ba
@ -1121,6 +1121,7 @@ void IRGeneratorForStatements::endVisit(FunctionCall const& _functionCall)
|
|||||||
"))\n";
|
"))\n";
|
||||||
IRVariable selectorVariable(m_context.newYulVariable(), *TypeProvider::fixedBytes(4));
|
IRVariable selectorVariable(m_context.newYulVariable(), *TypeProvider::fixedBytes(4));
|
||||||
define(selectorVariable, hashVariable);
|
define(selectorVariable, hashVariable);
|
||||||
|
selector = selectorVariable.name();
|
||||||
m_code << "mstore(" << to_string(CompilerUtils::freeMemoryPointer) << ", " << freeMemoryPre << ")\n";
|
m_code << "mstore(" << to_string(CompilerUtils::freeMemoryPointer) << ", " << freeMemoryPre << ")\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
contract C {
|
||||||
|
function f() public pure returns (bytes memory r1, bytes memory r2) {
|
||||||
|
string memory x = "my_signature";
|
||||||
|
r1 = abi.encodeWithSignature("my_signature", 1);
|
||||||
|
r2 = abi.encodeWithSignature(x, 1);
|
||||||
|
assert(r1.length == r2.length);
|
||||||
|
for (uint i = 0; i < r1.length; i++)
|
||||||
|
assert(r1[i] == r2[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ====
|
||||||
|
// compileToEwasm: false
|
||||||
|
// compileViaYul: also
|
||||||
|
// ----
|
||||||
|
// f() -> 0x40, 0xa0, 0x24, -813742827273327954027712588510533233455028711326166692885570228492575965184, 26959946667150639794667015087019630673637144422540572481103610249216, 0x24, -813742827273327954027712588510533233455028711326166692885570228492575965184, 26959946667150639794667015087019630673637144422540572481103610249216
|
Loading…
Reference in New Issue
Block a user