solidity/test/libsolidity/semanticTests/libraries/bound_to_calldata.sol

20 lines
559 B
Solidity
Raw Normal View History

library D {
2020-12-14 17:34:40 +00:00
function f(bytes calldata _x) internal pure returns (bytes1) {
return _x[0];
}
2020-12-14 17:34:40 +00:00
function g(bytes memory _x) internal pure returns (bytes1) {
return _x[0];
}
}
contract C {
using D for bytes;
2020-12-14 17:34:40 +00:00
function f(bytes calldata _x) public pure returns (bytes1, bytes1) {
return (_x.f(), _x.g());
}
}
// ====
// compileViaYul: also
// ----
// f(bytes): 0x20, 4, "abcd" -> 0x6100000000000000000000000000000000000000000000000000000000000000, 0x6100000000000000000000000000000000000000000000000000000000000000