aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp20
-rw-r--r--test/libsolidity/syntaxTests/constructor/abstract_creation_forward_reference.sol15
-rw-r--r--test/libsolidity/syntaxTests/deprecated_functions.sol4
-rw-r--r--test/libsolidity/syntaxTests/globalFunctions/sha3_no_call.sol8
-rw-r--r--test/libsolidity/syntaxTests/globalFunctions/sha3_override.sol11
-rw-r--r--test/libsolidity/syntaxTests/globalFunctions/sha3_var.sol9
-rw-r--r--test/libsolidity/syntaxTests/globalFunctions/suicide_no_call.sol8
-rw-r--r--test/libsolidity/syntaxTests/globalFunctions/suicide_override.sol11
-rw-r--r--test/libsolidity/syntaxTests/globalFunctions/suicide_var.sol9
-rw-r--r--test/libsolidity/syntaxTests/inline_arrays/dynamic_inline_array.sol (renamed from test/libsolidity/syntaxTests/nameAndTypeResolution/277_dynamic_inline_array.sol)0
-rw-r--r--test/libsolidity/syntaxTests/inline_arrays/inline_array_declaration_and_passing_implicit_conversion.sol (renamed from test/libsolidity/syntaxTests/nameAndTypeResolution/269_inline_array_declaration_and_passing_implicit_conversion.sol)0
-rw-r--r--test/libsolidity/syntaxTests/inline_arrays/inline_array_declaration_and_passing_implicit_conversion_strings.sol (renamed from test/libsolidity/syntaxTests/nameAndTypeResolution/270_inline_array_declaration_and_passing_implicit_conversion_strings.sol)0
-rw-r--r--test/libsolidity/syntaxTests/inline_arrays/inline_array_declaration_const_int_conversion.sol (renamed from test/libsolidity/syntaxTests/nameAndTypeResolution/271_inline_array_declaration_const_int_conversion.sol)0
-rw-r--r--test/libsolidity/syntaxTests/inline_arrays/inline_array_declaration_const_string_conversion.sol (renamed from test/libsolidity/syntaxTests/nameAndTypeResolution/272_inline_array_declaration_const_string_conversion.sol)0
-rw-r--r--test/libsolidity/syntaxTests/inline_arrays/inline_array_declaration_no_type.sol (renamed from test/libsolidity/syntaxTests/nameAndTypeResolution/273_inline_array_declaration_no_type.sol)0
-rw-r--r--test/libsolidity/syntaxTests/inline_arrays/inline_array_declaration_no_type_strings.sol (renamed from test/libsolidity/syntaxTests/nameAndTypeResolution/274_inline_array_declaration_no_type_strings.sol)0
-rw-r--r--test/libsolidity/syntaxTests/inline_arrays/inline_array_fixed_types.sol (renamed from test/libsolidity/syntaxTests/nameAndTypeResolution/325_inline_array_fixed_types.sol)0
-rw-r--r--test/libsolidity/syntaxTests/inline_arrays/inline_array_of_mapping_type.sol8
-rw-r--r--test/libsolidity/syntaxTests/inline_arrays/inline_array_rationals.sol (renamed from test/libsolidity/syntaxTests/nameAndTypeResolution/326_inline_array_rationals.sol)0
-rw-r--r--test/libsolidity/syntaxTests/inline_arrays/invalid_types_in_inline_array.sol (renamed from test/libsolidity/syntaxTests/nameAndTypeResolution/276_invalid_types_in_inline_array.sol)0
-rw-r--r--test/libsolidity/syntaxTests/inline_arrays/lvalues_as_inline_array.sol (renamed from test/libsolidity/syntaxTests/nameAndTypeResolution/278_lvalues_as_inline_array.sol)0
-rw-r--r--test/libsolidity/syntaxTests/memberLookup/internal_function_type.sol7
-rw-r--r--test/libsolidity/syntaxTests/structs/recursion/recursive_struct_forward_reference.sol11
23 files changed, 119 insertions, 2 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 05bb7446..c6135a72 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -14213,6 +14213,26 @@ BOOST_AUTO_TEST_CASE(external_public_override)
ABI_CHECK(callContractFunction("f()"), encodeArgs(2));
ABI_CHECK(callContractFunction("g()"), encodeArgs(2));
}
+
+BOOST_AUTO_TEST_CASE(base_access_to_function_type_variables)
+{
+ char const* sourceCode = R"(
+ contract C {
+ function () internal returns (uint) x;
+ function set() public {
+ C.x = g;
+ }
+ function g() public pure returns (uint) { return 2; }
+ function h() public returns (uint) { return C.x(); }
+ }
+ )";
+ compileAndRun(sourceCode);
+ ABI_CHECK(callContractFunction("g()"), encodeArgs(2));
+ ABI_CHECK(callContractFunction("h()"), encodeArgs());
+ ABI_CHECK(callContractFunction("set()"), encodeArgs());
+ ABI_CHECK(callContractFunction("h()"), encodeArgs(2));
+}
+
BOOST_AUTO_TEST_SUITE_END()
}
diff --git a/test/libsolidity/syntaxTests/constructor/abstract_creation_forward_reference.sol b/test/libsolidity/syntaxTests/constructor/abstract_creation_forward_reference.sol
new file mode 100644
index 00000000..2e6aeaa5
--- /dev/null
+++ b/test/libsolidity/syntaxTests/constructor/abstract_creation_forward_reference.sol
@@ -0,0 +1,15 @@
+// This used to cause an internal error because of the visitation order.
+contract Test {
+ function createChild() public {
+ Child asset = new Child();
+ }
+}
+
+contract Parent {
+ constructor(address _address) public {}
+}
+
+contract Child is Parent {
+}
+// ----
+// TypeError: (146-155): Trying to create an instance of an abstract contract.
diff --git a/test/libsolidity/syntaxTests/deprecated_functions.sol b/test/libsolidity/syntaxTests/deprecated_functions.sol
index 62dfcff9..c5764e96 100644
--- a/test/libsolidity/syntaxTests/deprecated_functions.sol
+++ b/test/libsolidity/syntaxTests/deprecated_functions.sol
@@ -8,5 +8,5 @@ contract test {
}
}
// ----
-// TypeError: (58-66): "sha3" has been deprecated in favour of "keccak256"
-// TypeError: (101-152): "suicide" has been deprecated in favour of "selfdestruct"
+// TypeError: (58-62): "sha3" has been deprecated in favour of "keccak256"
+// TypeError: (101-108): "suicide" has been deprecated in favour of "selfdestruct"
diff --git a/test/libsolidity/syntaxTests/globalFunctions/sha3_no_call.sol b/test/libsolidity/syntaxTests/globalFunctions/sha3_no_call.sol
new file mode 100644
index 00000000..37b60e5e
--- /dev/null
+++ b/test/libsolidity/syntaxTests/globalFunctions/sha3_no_call.sol
@@ -0,0 +1,8 @@
+contract C
+{
+ function f(bytes memory data) public pure {
+ sha3;
+ }
+}
+// ----
+// TypeError: (60-64): "sha3" has been deprecated in favour of "keccak256"
diff --git a/test/libsolidity/syntaxTests/globalFunctions/sha3_override.sol b/test/libsolidity/syntaxTests/globalFunctions/sha3_override.sol
new file mode 100644
index 00000000..909c2dc3
--- /dev/null
+++ b/test/libsolidity/syntaxTests/globalFunctions/sha3_override.sol
@@ -0,0 +1,11 @@
+contract C
+{
+ function sha3() public pure returns (bool) {
+ return true;
+ }
+ function f() public pure returns (bool) {
+ return sha3();
+ }
+}
+// ----
+// Warning: (14-76): This declaration shadows a builtin symbol.
diff --git a/test/libsolidity/syntaxTests/globalFunctions/sha3_var.sol b/test/libsolidity/syntaxTests/globalFunctions/sha3_var.sol
new file mode 100644
index 00000000..19ee72d9
--- /dev/null
+++ b/test/libsolidity/syntaxTests/globalFunctions/sha3_var.sol
@@ -0,0 +1,9 @@
+contract C
+{
+ function f() public pure returns (bool) {
+ bool sha3 = true;
+ return sha3;
+ }
+}
+// ----
+// Warning: (58-67): This declaration shadows a builtin symbol.
diff --git a/test/libsolidity/syntaxTests/globalFunctions/suicide_no_call.sol b/test/libsolidity/syntaxTests/globalFunctions/suicide_no_call.sol
new file mode 100644
index 00000000..bf3f5ebc
--- /dev/null
+++ b/test/libsolidity/syntaxTests/globalFunctions/suicide_no_call.sol
@@ -0,0 +1,8 @@
+contract C
+{
+ function f(bytes memory data) public pure {
+ suicide;
+ }
+}
+// ----
+// TypeError: (60-67): "suicide" has been deprecated in favour of "selfdestruct"
diff --git a/test/libsolidity/syntaxTests/globalFunctions/suicide_override.sol b/test/libsolidity/syntaxTests/globalFunctions/suicide_override.sol
new file mode 100644
index 00000000..7350da39
--- /dev/null
+++ b/test/libsolidity/syntaxTests/globalFunctions/suicide_override.sol
@@ -0,0 +1,11 @@
+contract C
+{
+ function suicide() public pure returns (bool) {
+ return true;
+ }
+ function f() public pure returns (bool) {
+ return suicide();
+ }
+}
+// ----
+// Warning: (14-79): This declaration shadows a builtin symbol.
diff --git a/test/libsolidity/syntaxTests/globalFunctions/suicide_var.sol b/test/libsolidity/syntaxTests/globalFunctions/suicide_var.sol
new file mode 100644
index 00000000..3549a563
--- /dev/null
+++ b/test/libsolidity/syntaxTests/globalFunctions/suicide_var.sol
@@ -0,0 +1,9 @@
+contract C
+{
+ function f() public pure returns (bool) {
+ bool suicide = true;
+ return suicide;
+ }
+}
+// ----
+// Warning: (58-70): This declaration shadows a builtin symbol.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/277_dynamic_inline_array.sol b/test/libsolidity/syntaxTests/inline_arrays/dynamic_inline_array.sol
index e613758b..e613758b 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/277_dynamic_inline_array.sol
+++ b/test/libsolidity/syntaxTests/inline_arrays/dynamic_inline_array.sol
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/269_inline_array_declaration_and_passing_implicit_conversion.sol b/test/libsolidity/syntaxTests/inline_arrays/inline_array_declaration_and_passing_implicit_conversion.sol
index 023404f7..023404f7 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/269_inline_array_declaration_and_passing_implicit_conversion.sol
+++ b/test/libsolidity/syntaxTests/inline_arrays/inline_array_declaration_and_passing_implicit_conversion.sol
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/270_inline_array_declaration_and_passing_implicit_conversion_strings.sol b/test/libsolidity/syntaxTests/inline_arrays/inline_array_declaration_and_passing_implicit_conversion_strings.sol
index 025244d3..025244d3 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/270_inline_array_declaration_and_passing_implicit_conversion_strings.sol
+++ b/test/libsolidity/syntaxTests/inline_arrays/inline_array_declaration_and_passing_implicit_conversion_strings.sol
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/271_inline_array_declaration_const_int_conversion.sol b/test/libsolidity/syntaxTests/inline_arrays/inline_array_declaration_const_int_conversion.sol
index e7036bdf..e7036bdf 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/271_inline_array_declaration_const_int_conversion.sol
+++ b/test/libsolidity/syntaxTests/inline_arrays/inline_array_declaration_const_int_conversion.sol
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/272_inline_array_declaration_const_string_conversion.sol b/test/libsolidity/syntaxTests/inline_arrays/inline_array_declaration_const_string_conversion.sol
index 4e92f6e1..4e92f6e1 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/272_inline_array_declaration_const_string_conversion.sol
+++ b/test/libsolidity/syntaxTests/inline_arrays/inline_array_declaration_const_string_conversion.sol
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/273_inline_array_declaration_no_type.sol b/test/libsolidity/syntaxTests/inline_arrays/inline_array_declaration_no_type.sol
index 4d3e6aed..4d3e6aed 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/273_inline_array_declaration_no_type.sol
+++ b/test/libsolidity/syntaxTests/inline_arrays/inline_array_declaration_no_type.sol
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/274_inline_array_declaration_no_type_strings.sol b/test/libsolidity/syntaxTests/inline_arrays/inline_array_declaration_no_type_strings.sol
index 6d36942d..6d36942d 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/274_inline_array_declaration_no_type_strings.sol
+++ b/test/libsolidity/syntaxTests/inline_arrays/inline_array_declaration_no_type_strings.sol
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/325_inline_array_fixed_types.sol b/test/libsolidity/syntaxTests/inline_arrays/inline_array_fixed_types.sol
index c46297c3..c46297c3 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/325_inline_array_fixed_types.sol
+++ b/test/libsolidity/syntaxTests/inline_arrays/inline_array_fixed_types.sol
diff --git a/test/libsolidity/syntaxTests/inline_arrays/inline_array_of_mapping_type.sol b/test/libsolidity/syntaxTests/inline_arrays/inline_array_of_mapping_type.sol
new file mode 100644
index 00000000..59a88130
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inline_arrays/inline_array_of_mapping_type.sol
@@ -0,0 +1,8 @@
+contract C {
+ mapping(int => int) a;
+ function f() public {
+ [a];
+ }
+}
+// ----
+// TypeError: (66-69): Type mapping(int256 => int256) is only valid in storage.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/326_inline_array_rationals.sol b/test/libsolidity/syntaxTests/inline_arrays/inline_array_rationals.sol
index bdc3c2c1..bdc3c2c1 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/326_inline_array_rationals.sol
+++ b/test/libsolidity/syntaxTests/inline_arrays/inline_array_rationals.sol
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/276_invalid_types_in_inline_array.sol b/test/libsolidity/syntaxTests/inline_arrays/invalid_types_in_inline_array.sol
index 03d7266a..03d7266a 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/276_invalid_types_in_inline_array.sol
+++ b/test/libsolidity/syntaxTests/inline_arrays/invalid_types_in_inline_array.sol
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/278_lvalues_as_inline_array.sol b/test/libsolidity/syntaxTests/inline_arrays/lvalues_as_inline_array.sol
index 5a39f550..5a39f550 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/278_lvalues_as_inline_array.sol
+++ b/test/libsolidity/syntaxTests/inline_arrays/lvalues_as_inline_array.sol
diff --git a/test/libsolidity/syntaxTests/memberLookup/internal_function_type.sol b/test/libsolidity/syntaxTests/memberLookup/internal_function_type.sol
new file mode 100644
index 00000000..560a6c2a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/memberLookup/internal_function_type.sol
@@ -0,0 +1,7 @@
+contract C {
+ function () internal returns (uint) x;
+ constructor() public {
+ C.x = g;
+ }
+ function g() public pure returns (uint) {}
+}
diff --git a/test/libsolidity/syntaxTests/structs/recursion/recursive_struct_forward_reference.sol b/test/libsolidity/syntaxTests/structs/recursion/recursive_struct_forward_reference.sol
new file mode 100644
index 00000000..d2a411ec
--- /dev/null
+++ b/test/libsolidity/syntaxTests/structs/recursion/recursive_struct_forward_reference.sol
@@ -0,0 +1,11 @@
+pragma experimental ABIEncoderV2;
+
+contract C {
+ function f(Data.S memory a) public {}
+}
+contract Data {
+ struct S { S x; }
+}
+// ----
+// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments.
+// TypeError: (63-78): Internal or recursive type is not allowed for public or external functions.