Merge pull request #9173 from ethereum/fixBoundCalldata

Fix bound functions with calldata parameters.
This commit is contained in:
chriseth
2020-06-11 13:31:30 +02:00
committed by GitHub
10 changed files with 131 additions and 12 deletions
@@ -0,0 +1,17 @@
library D {
function f(bytes calldata _x) internal pure returns (bytes calldata) {
return _x;
}
function g(bytes calldata _x) internal pure returns (bytes memory) {
return _x;
}
}
contract C {
using D for bytes;
function f(bytes calldata _x) public pure returns (byte, byte) {
return (_x.f()[0], _x.g()[0]);
}
}
// ----
// f(bytes): 0x20, 4, "abcd" -> 0x6100000000000000000000000000000000000000000000000000000000000000, 0x6100000000000000000000000000000000000000000000000000000000000000
@@ -0,0 +1,20 @@
library D {
function f(bytes calldata _x) public pure returns (bytes calldata) {
return _x;
}
function g(bytes calldata _x) public pure returns (bytes memory) {
return _x;
}
}
contract C {
using D for bytes;
function f(bytes calldata _x) public pure returns (byte, byte) {
return (_x.f()[0], _x.g()[0]);
}
}
// ====
// EVMVersion: >homestead
// ----
// library: D
// f(bytes): 0x20, 4, "abcd" -> 0x6100000000000000000000000000000000000000000000000000000000000000, 0x6100000000000000000000000000000000000000000000000000000000000000
@@ -0,0 +1,17 @@
library D {
function f(bytes calldata _x) internal pure returns (byte) {
return _x[0];
}
function g(bytes memory _x) internal pure returns (byte) {
return _x[0];
}
}
contract C {
using D for bytes;
function f(bytes calldata _x) public pure returns (byte, byte) {
return (_x.f(), _x.g());
}
}
// ----
// f(bytes): 0x20, 4, "abcd" -> 0x6100000000000000000000000000000000000000000000000000000000000000, 0x6100000000000000000000000000000000000000000000000000000000000000
@@ -0,0 +1,20 @@
library D {
function f(bytes calldata _x) public pure returns (byte) {
return _x[0];
}
function g(bytes memory _x) public pure returns (byte) {
return _x[0];
}
}
contract C {
using D for bytes;
function f(bytes calldata _x) public pure returns (byte, byte) {
return (_x.f(), _x.g());
}
}
// ====
// EVMVersion: >homestead
// ----
// library: D
// f(bytes): 0x20, 4, "abcd" -> 0x6100000000000000000000000000000000000000000000000000000000000000, 0x6100000000000000000000000000000000000000000000000000000000000000
@@ -0,0 +1,9 @@
library D { function f(bytes calldata) internal pure {} }
contract C {
using D for bytes;
function f(bytes memory _x) public pure {
_x.f();
}
}
// ----
// TypeError: (136-140): Member "f" not found or not visible after argument-dependent lookup in bytes memory.