aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/syntaxTests/inheritance
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-12-03 22:48:03 +0800
committerGitHub <noreply@github.com>2018-12-03 22:48:03 +0800
commitc8a2cb62832afb2dc09ccee6fd42c1516dfdb981 (patch)
tree7977e9dcbbc215088c05b847f849871ef5d4ae66 /test/libsolidity/syntaxTests/inheritance
parent1d4f565a64988a3400847d2655ca24f73f234bc6 (diff)
parent590be1d84cea9850ce69b68be3dc5294b39041e5 (diff)
downloaddexon-solidity-c8a2cb62832afb2dc09ccee6fd42c1516dfdb981.tar
dexon-solidity-c8a2cb62832afb2dc09ccee6fd42c1516dfdb981.tar.gz
dexon-solidity-c8a2cb62832afb2dc09ccee6fd42c1516dfdb981.tar.bz2
dexon-solidity-c8a2cb62832afb2dc09ccee6fd42c1516dfdb981.tar.lz
dexon-solidity-c8a2cb62832afb2dc09ccee6fd42c1516dfdb981.tar.xz
dexon-solidity-c8a2cb62832afb2dc09ccee6fd42c1516dfdb981.tar.zst
dexon-solidity-c8a2cb62832afb2dc09ccee6fd42c1516dfdb981.zip
Merge pull request #5571 from ethereum/develop
Version 0.5.1
Diffstat (limited to 'test/libsolidity/syntaxTests/inheritance')
-rw-r--r--test/libsolidity/syntaxTests/inheritance/override/calldata_memory.sol13
-rw-r--r--test/libsolidity/syntaxTests/inheritance/override/calldata_memory_conflict.sol26
-rw-r--r--test/libsolidity/syntaxTests/inheritance/override/calldata_memory_interface.sol13
-rw-r--r--test/libsolidity/syntaxTests/inheritance/override/calldata_memory_interface_instantiate.sol12
-rw-r--r--test/libsolidity/syntaxTests/inheritance/override/calldata_memory_interface_struct.sol17
-rw-r--r--test/libsolidity/syntaxTests/inheritance/override/calldata_memory_struct.sol17
-rw-r--r--test/libsolidity/syntaxTests/inheritance/override/change_return_types_in_interface.sol10
-rw-r--r--test/libsolidity/syntaxTests/inheritance/override/external_turns_public_no_params.sol7
-rw-r--r--test/libsolidity/syntaxTests/inheritance/override/implement_interface_by_public_variable.sol7
-rw-r--r--test/libsolidity/syntaxTests/inheritance/override/implement_internal_function_by_public_variable.sol9
-rw-r--r--test/libsolidity/syntaxTests/inheritance/override/implement_private_function_by_public_variable.sol7
-rw-r--r--test/libsolidity/syntaxTests/inheritance/override/implement_public_function_by_public_variable.sol9
-rw-r--r--test/libsolidity/syntaxTests/inheritance/override/internal_external.sol7
-rw-r--r--test/libsolidity/syntaxTests/inheritance/override/internal_external_inheritance.sol9
-rw-r--r--test/libsolidity/syntaxTests/inheritance/override/state_variable_function.sol1
-rw-r--r--test/libsolidity/syntaxTests/inheritance/super_on_external.sol10
16 files changed, 174 insertions, 0 deletions
diff --git a/test/libsolidity/syntaxTests/inheritance/override/calldata_memory.sol b/test/libsolidity/syntaxTests/inheritance/override/calldata_memory.sol
new file mode 100644
index 00000000..e683ef39
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inheritance/override/calldata_memory.sol
@@ -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 {}
+}
diff --git a/test/libsolidity/syntaxTests/inheritance/override/calldata_memory_conflict.sol b/test/libsolidity/syntaxTests/inheritance/override/calldata_memory_conflict.sol
new file mode 100644
index 00000000..dc734d36
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inheritance/override/calldata_memory_conflict.sol
@@ -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.
diff --git a/test/libsolidity/syntaxTests/inheritance/override/calldata_memory_interface.sol b/test/libsolidity/syntaxTests/inheritance/override/calldata_memory_interface.sol
new file mode 100644
index 00000000..7eecc079
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inheritance/override/calldata_memory_interface.sol
@@ -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 {}
+}
diff --git a/test/libsolidity/syntaxTests/inheritance/override/calldata_memory_interface_instantiate.sol b/test/libsolidity/syntaxTests/inheritance/override/calldata_memory_interface_instantiate.sol
new file mode 100644
index 00000000..4cdc3924
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inheritance/override/calldata_memory_interface_instantiate.sol
@@ -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));
+ }
+} \ No newline at end of file
diff --git a/test/libsolidity/syntaxTests/inheritance/override/calldata_memory_interface_struct.sol b/test/libsolidity/syntaxTests/inheritance/override/calldata_memory_interface_struct.sol
new file mode 100644
index 00000000..49b27fd7
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inheritance/override/calldata_memory_interface_struct.sol
@@ -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.
diff --git a/test/libsolidity/syntaxTests/inheritance/override/calldata_memory_struct.sol b/test/libsolidity/syntaxTests/inheritance/override/calldata_memory_struct.sol
new file mode 100644
index 00000000..42aebf30
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inheritance/override/calldata_memory_struct.sol
@@ -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.
diff --git a/test/libsolidity/syntaxTests/inheritance/override/change_return_types_in_interface.sol b/test/libsolidity/syntaxTests/inheritance/override/change_return_types_in_interface.sol
new file mode 100644
index 00000000..804a1810
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inheritance/override/change_return_types_in_interface.sol
@@ -0,0 +1,10 @@
+interface I {
+ function f() external pure returns (uint);
+}
+contract B is I {
+ // The compiler used to have a bug where changing
+ // the return type was fine in this situation.
+ function f() public pure returns (uint, uint) {}
+}
+// ----
+// TypeError: (182-230): Overriding function return types differ.
diff --git a/test/libsolidity/syntaxTests/inheritance/override/external_turns_public_no_params.sol b/test/libsolidity/syntaxTests/inheritance/override/external_turns_public_no_params.sol
new file mode 100644
index 00000000..3d0394f5
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inheritance/override/external_turns_public_no_params.sol
@@ -0,0 +1,7 @@
+contract A {
+ function f() external pure {}
+}
+contract B is A {
+ function f() public pure {
+ }
+}
diff --git a/test/libsolidity/syntaxTests/inheritance/override/implement_interface_by_public_variable.sol b/test/libsolidity/syntaxTests/inheritance/override/implement_interface_by_public_variable.sol
new file mode 100644
index 00000000..49f7c33b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inheritance/override/implement_interface_by_public_variable.sol
@@ -0,0 +1,7 @@
+interface X { function test() external returns (uint256); }
+contract Y is X {
+ uint256 public test = 42;
+}
+contract T {
+ constructor() public { new Y(); }
+}
diff --git a/test/libsolidity/syntaxTests/inheritance/override/implement_internal_function_by_public_variable.sol b/test/libsolidity/syntaxTests/inheritance/override/implement_internal_function_by_public_variable.sol
new file mode 100644
index 00000000..32fac25c
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inheritance/override/implement_internal_function_by_public_variable.sol
@@ -0,0 +1,9 @@
+contract X { function test() internal returns (uint256); }
+contract Y is X {
+ uint256 public test = 42;
+}
+contract T {
+ constructor() public { new Y(); }
+}
+// ----
+// DeclarationError: (81-105): Identifier already declared.
diff --git a/test/libsolidity/syntaxTests/inheritance/override/implement_private_function_by_public_variable.sol b/test/libsolidity/syntaxTests/inheritance/override/implement_private_function_by_public_variable.sol
new file mode 100644
index 00000000..c58e24b6
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inheritance/override/implement_private_function_by_public_variable.sol
@@ -0,0 +1,7 @@
+contract X { function test() private returns (uint256); }
+contract Y is X {
+ uint256 public test = 42;
+}
+contract T {
+ constructor() public { new Y(); }
+}
diff --git a/test/libsolidity/syntaxTests/inheritance/override/implement_public_function_by_public_variable.sol b/test/libsolidity/syntaxTests/inheritance/override/implement_public_function_by_public_variable.sol
new file mode 100644
index 00000000..7a59c137
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inheritance/override/implement_public_function_by_public_variable.sol
@@ -0,0 +1,9 @@
+contract X { function test() public returns (uint256); }
+contract Y is X {
+ uint256 public test = 42;
+}
+contract T {
+ constructor() public { new Y(); }
+}
+// ----
+// DeclarationError: (79-103): Identifier already declared.
diff --git a/test/libsolidity/syntaxTests/inheritance/override/internal_external.sol b/test/libsolidity/syntaxTests/inheritance/override/internal_external.sol
new file mode 100644
index 00000000..90973ee7
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inheritance/override/internal_external.sol
@@ -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.
diff --git a/test/libsolidity/syntaxTests/inheritance/override/internal_external_inheritance.sol b/test/libsolidity/syntaxTests/inheritance/override/internal_external_inheritance.sol
new file mode 100644
index 00000000..c09a8000
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inheritance/override/internal_external_inheritance.sol
@@ -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.
diff --git a/test/libsolidity/syntaxTests/inheritance/override/state_variable_function.sol b/test/libsolidity/syntaxTests/inheritance/override/state_variable_function.sol
index 0f05cc8e..fb7f3fbd 100644
--- a/test/libsolidity/syntaxTests/inheritance/override/state_variable_function.sol
+++ b/test/libsolidity/syntaxTests/inheritance/override/state_variable_function.sol
@@ -6,3 +6,4 @@ contract C is A {
}
// ----
// DeclarationError: (50-85): Identifier already declared.
+// TypeError: (50-85): Redeclaring an already implemented function as abstract
diff --git a/test/libsolidity/syntaxTests/inheritance/super_on_external.sol b/test/libsolidity/syntaxTests/inheritance/super_on_external.sol
new file mode 100644
index 00000000..21f3b1c2
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inheritance/super_on_external.sol
@@ -0,0 +1,10 @@
+contract A {
+ function f() external pure {}
+}
+contract B is A {
+ function f() public pure {
+ super.f();
+ }
+}
+// ----
+// TypeError: (106-113): Member "f" not found or not visible after argument-dependent lookup in contract super B.