mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
More strict override check for data locations.
This commit is contained in:
+14
@@ -0,0 +1,14 @@
|
||||
abstract contract A {
|
||||
function f(uint256[1] memory a) external virtual returns (uint256);
|
||||
}
|
||||
contract B is A {
|
||||
function f(uint256[1] calldata a) external pure virtual override returns (uint256) {
|
||||
return a[0];
|
||||
}
|
||||
}
|
||||
contract C is A, B {
|
||||
function f(uint256[1] memory a) external pure override(B, A) returns (uint256) {
|
||||
return a[0];
|
||||
}
|
||||
}
|
||||
// ----
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
abstract contract A {
|
||||
modifier m(uint256[1] memory a) virtual;
|
||||
function test(uint256[1] memory a) m(a) external {
|
||||
}
|
||||
}
|
||||
|
||||
contract B is A {
|
||||
modifier m(uint256[1] calldata a) override {
|
||||
_;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 1078: (153-214): Override changes modifier signature.
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
abstract contract A {
|
||||
function f(uint256[1] calldata a) public virtual returns (uint256);
|
||||
}
|
||||
|
||||
contract B is A {
|
||||
function f(uint256[1] memory a) public override returns (uint256) {
|
||||
return a[0];
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 7723: (119-213): Data locations of parameters have to be the same when overriding non-external functions, but they differ.
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
abstract contract A {
|
||||
function f(uint256[1] memory a) internal virtual returns (uint256);
|
||||
function test() external returns (uint) {
|
||||
uint[1] memory t;
|
||||
t[0] = 7;
|
||||
return f(t);
|
||||
}
|
||||
}
|
||||
|
||||
contract B is A {
|
||||
function f(uint256[1] calldata a) internal override returns (uint256) {
|
||||
return a[0];
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 7723: (236-334): Data locations of parameters have to be the same when overriding non-external functions, but they differ.
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
abstract contract A {
|
||||
function f(uint256[1] memory a) public virtual returns (uint256);
|
||||
function test() external returns (uint) {
|
||||
uint[1] memory t;
|
||||
t[0] = 7;
|
||||
return f(t);
|
||||
}
|
||||
}
|
||||
|
||||
contract B is A {
|
||||
function f(uint256[1] calldata a) public override returns (uint256) {
|
||||
return a[0];
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 7723: (234-330): Data locations of parameters have to be the same when overriding non-external functions, but they differ.
|
||||
@@ -0,0 +1,7 @@
|
||||
abstract contract A {
|
||||
function foo() external virtual view returns(uint[] calldata);
|
||||
}
|
||||
contract X is A {
|
||||
function foo() public view override returns(uint[] memory) { }
|
||||
}
|
||||
// ----
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
abstract contract A {
|
||||
function foo() public virtual view returns(uint[] calldata);
|
||||
}
|
||||
contract X is A {
|
||||
function foo() public view override returns(uint[] memory) { }
|
||||
}
|
||||
// ----
|
||||
// TypeError 1443: (105-168): Data locations of return variables have to be the same when overriding non-external functions, but they differ.
|
||||
Reference in New Issue
Block a user