mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Tests.
This commit is contained in:
committed by
chriseth
parent
5ec634939e
commit
597174119a
@@ -0,0 +1,13 @@
|
||||
contract A {
|
||||
uint dummy;
|
||||
function f(uint[] calldata) external pure {}
|
||||
function g(uint[] calldata) external view { dummy; }
|
||||
function h(uint[] calldata) external { dummy = 42; }
|
||||
function i(uint[] calldata) external payable {}
|
||||
}
|
||||
contract B is A {
|
||||
function f(uint[] memory) public pure {}
|
||||
function g(uint[] memory) public view { dummy; }
|
||||
function h(uint[] memory) public { dummy = 42; }
|
||||
function i(uint[] memory) public payable {}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
contract A {
|
||||
uint dummy;
|
||||
function f(uint[] calldata) external pure {}
|
||||
function g(uint[] calldata) external view { dummy; }
|
||||
function h(uint[] calldata) external { dummy = 42; }
|
||||
function i(uint[] calldata) external payable {}
|
||||
}
|
||||
contract B is A {
|
||||
function f(uint[] calldata) external pure {}
|
||||
function g(uint[] calldata) external view { dummy; }
|
||||
function h(uint[] calldata) external { dummy = 42; }
|
||||
function i(uint[] calldata) external payable {}
|
||||
function f(uint[] memory) public pure {}
|
||||
function g(uint[] memory) public view { dummy; }
|
||||
function h(uint[] memory) public { dummy = 42; }
|
||||
function i(uint[] memory) public payable {}
|
||||
}
|
||||
// ----
|
||||
// DeclarationError: (268-312): Function with same name and arguments defined twice.
|
||||
// DeclarationError: (317-369): Function with same name and arguments defined twice.
|
||||
// DeclarationError: (374-426): Function with same name and arguments defined twice.
|
||||
// DeclarationError: (431-478): Function with same name and arguments defined twice.
|
||||
// TypeError: (268-312): Overriding function visibility differs.
|
||||
// TypeError: (317-369): Overriding function visibility differs.
|
||||
// TypeError: (374-426): Overriding function visibility differs.
|
||||
// TypeError: (431-478): Overriding function visibility differs.
|
||||
@@ -0,0 +1,13 @@
|
||||
interface I {
|
||||
function f(uint[] calldata) external pure;
|
||||
function g(uint[] calldata) external view;
|
||||
function h(uint[] calldata) external;
|
||||
function i(uint[] calldata) external payable;
|
||||
}
|
||||
contract C is I {
|
||||
uint dummy;
|
||||
function f(uint[] memory) public pure {}
|
||||
function g(uint[] memory) public view { dummy; }
|
||||
function h(uint[] memory) public { dummy = 42; }
|
||||
function i(uint[] memory) public payable {}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
interface I {
|
||||
function f(uint[] calldata) external pure;
|
||||
}
|
||||
contract A is I {
|
||||
function f(uint[] memory) public pure {}
|
||||
}
|
||||
contract C {
|
||||
function f() public {
|
||||
I i = I(new A());
|
||||
i.f(new uint[](1));
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
interface I {
|
||||
struct S { int a; }
|
||||
function f(S calldata) external pure;
|
||||
function g(S calldata) external view;
|
||||
function h(S calldata) external;
|
||||
function i(S calldata) external payable;
|
||||
}
|
||||
contract C is I {
|
||||
uint dummy;
|
||||
function f(S memory) public pure {}
|
||||
function g(S memory) public view { dummy; }
|
||||
function h(S memory) public { dummy = 42; }
|
||||
function i(S memory) public payable {}
|
||||
}
|
||||
// ----
|
||||
// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments.
|
||||
@@ -0,0 +1,17 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
contract A {
|
||||
uint dummy;
|
||||
struct S { int a; }
|
||||
function f(S calldata) external pure {}
|
||||
function g(S calldata) external view { dummy; }
|
||||
function h(S calldata) external { dummy = 42; }
|
||||
function i(S calldata) external payable {}
|
||||
}
|
||||
contract B is A {
|
||||
function f(S memory) public pure {}
|
||||
function g(S memory) public view { dummy; }
|
||||
function h(S memory) public { dummy = 42; }
|
||||
function i(S memory) public payable {}
|
||||
}
|
||||
// ----
|
||||
// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments.
|
||||
@@ -0,0 +1,7 @@
|
||||
contract A {
|
||||
function f(uint[] calldata) external pure {}
|
||||
function f(uint[] memory) internal pure {}
|
||||
}
|
||||
// ----
|
||||
// DeclarationError: (17-61): Function with same name and arguments defined twice.
|
||||
// TypeError: (17-61): Overriding function visibility differs.
|
||||
@@ -0,0 +1,9 @@
|
||||
contract A {
|
||||
function f(uint[] calldata) external pure {}
|
||||
}
|
||||
contract B {
|
||||
function f(uint[] memory) internal pure {}
|
||||
}
|
||||
contract C is A, B {}
|
||||
// ----
|
||||
// TypeError: (81-123): Overriding function visibility differs.
|
||||
Reference in New Issue
Block a user