aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/syntaxTests
diff options
context:
space:
mode:
Diffstat (limited to 'test/libsolidity/syntaxTests')
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/mappingReturn/named_err.sol5
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/mappingReturn/named_fine.sol5
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/mappingReturn/unnamed_err.sol5
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/mappingReturn/unnamed_fine.sol5
-rw-r--r--test/libsolidity/syntaxTests/conversion/conversion_to_bytes.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/161_warns_assigning_decimal_to_bytesxx.sol5
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/162_does_not_warn_assigning_hex_number_to_bytesxx.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/163_explicit_conversion_from_decimal_to_bytesxx.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/186_invalid_utf8_explicit.sol2
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/419_interface_structs.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/482_explicit_literal_to_unspecified_string.sol2
-rw-r--r--test/libsolidity/syntaxTests/types/bytesm.sol2
-rw-r--r--test/libsolidity/syntaxTests/types/decimal_literal_to_bytesXX_explicit.sol23
-rw-r--r--test/libsolidity/syntaxTests/types/decimal_literal_to_bytesXX_implicit.sol23
-rw-r--r--test/libsolidity/syntaxTests/types/hex_literal_to_bytesXX_different_size_explicit.sol31
-rw-r--r--test/libsolidity/syntaxTests/types/hex_literal_to_bytesXX_different_size_implicit.sol31
-rw-r--r--test/libsolidity/syntaxTests/types/hex_literal_to_bytesXX_same_size_explicit.sol13
-rw-r--r--test/libsolidity/syntaxTests/types/hex_literal_to_bytesXX_same_size_implicit.sol13
-rw-r--r--test/libsolidity/syntaxTests/types/mapping/argument_external.sol7
-rw-r--r--test/libsolidity/syntaxTests/types/mapping/argument_internal.sol5
-rw-r--r--test/libsolidity/syntaxTests/types/mapping/argument_private.sol5
-rw-r--r--test/libsolidity/syntaxTests/types/mapping/argument_public.sol7
-rw-r--r--test/libsolidity/syntaxTests/types/mapping/array_argument_external.sol6
-rw-r--r--test/libsolidity/syntaxTests/types/mapping/array_argument_internal.sol5
-rw-r--r--test/libsolidity/syntaxTests/types/mapping/array_argument_private.sol5
-rw-r--r--test/libsolidity/syntaxTests/types/mapping/array_argument_public.sol6
-rw-r--r--test/libsolidity/syntaxTests/types/mapping/function_type_argument_external.sol6
-rw-r--r--test/libsolidity/syntaxTests/types/mapping/function_type_argument_internal.sol4
-rw-r--r--test/libsolidity/syntaxTests/types/mapping/function_type_return_external.sol6
-rw-r--r--test/libsolidity/syntaxTests/types/mapping/function_type_return_internal.sol4
-rw-r--r--test/libsolidity/syntaxTests/types/mapping/library_argument_external.sol6
-rw-r--r--test/libsolidity/syntaxTests/types/mapping/library_argument_internal.sol4
-rw-r--r--test/libsolidity/syntaxTests/types/mapping/library_argument_private.sol4
-rw-r--r--test/libsolidity/syntaxTests/types/mapping/library_argument_public.sol6
-rw-r--r--test/libsolidity/syntaxTests/types/mapping/library_array_argument_external.sol6
-rw-r--r--test/libsolidity/syntaxTests/types/mapping/library_array_argument_internal.sol4
-rw-r--r--test/libsolidity/syntaxTests/types/mapping/library_array_argument_private.sol4
-rw-r--r--test/libsolidity/syntaxTests/types/mapping/library_array_argument_public.sol6
-rw-r--r--test/libsolidity/syntaxTests/types/mapping/library_return_external.sol10
-rw-r--r--test/libsolidity/syntaxTests/types/mapping/library_return_internal.sol6
-rw-r--r--test/libsolidity/syntaxTests/types/mapping/library_return_private.sol6
-rw-r--r--test/libsolidity/syntaxTests/types/mapping/library_return_public.sol10
-rw-r--r--test/libsolidity/syntaxTests/types/mapping/mapping_array_return_external.sol6
-rw-r--r--test/libsolidity/syntaxTests/types/mapping/mapping_array_return_internal.sol16
-rw-r--r--test/libsolidity/syntaxTests/types/mapping/mapping_array_return_public.sol6
-rw-r--r--test/libsolidity/syntaxTests/types/mapping/mapping_return_internal.sol5
-rw-r--r--test/libsolidity/syntaxTests/types/zero_literal_to_bytesXX_explicit.sol30
-rw-r--r--test/libsolidity/syntaxTests/types/zero_literal_to_bytesXX_implicit.sol30
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/builtin_functions.sol2
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/builtin_functions_restrict_warning.sol8
50 files changed, 393 insertions, 27 deletions
diff --git a/test/libsolidity/syntaxTests/controlFlow/mappingReturn/named_err.sol b/test/libsolidity/syntaxTests/controlFlow/mappingReturn/named_err.sol
new file mode 100644
index 00000000..35420b6d
--- /dev/null
+++ b/test/libsolidity/syntaxTests/controlFlow/mappingReturn/named_err.sol
@@ -0,0 +1,5 @@
+contract C {
+ function f() internal pure returns (mapping(uint=>uint) storage r) { }
+}
+// ----
+// TypeError: (53-82): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
diff --git a/test/libsolidity/syntaxTests/controlFlow/mappingReturn/named_fine.sol b/test/libsolidity/syntaxTests/controlFlow/mappingReturn/named_fine.sol
new file mode 100644
index 00000000..4146192f
--- /dev/null
+++ b/test/libsolidity/syntaxTests/controlFlow/mappingReturn/named_fine.sol
@@ -0,0 +1,5 @@
+contract C {
+ mapping(uint=>uint) m;
+ function f() internal view returns (mapping(uint=>uint) storage r) { r = m; }
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/controlFlow/mappingReturn/unnamed_err.sol b/test/libsolidity/syntaxTests/controlFlow/mappingReturn/unnamed_err.sol
new file mode 100644
index 00000000..7e8c4501
--- /dev/null
+++ b/test/libsolidity/syntaxTests/controlFlow/mappingReturn/unnamed_err.sol
@@ -0,0 +1,5 @@
+contract C {
+ function f() internal pure returns (mapping(uint=>uint) storage) {}
+}
+// ----
+// TypeError: (53-72): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error.
diff --git a/test/libsolidity/syntaxTests/controlFlow/mappingReturn/unnamed_fine.sol b/test/libsolidity/syntaxTests/controlFlow/mappingReturn/unnamed_fine.sol
new file mode 100644
index 00000000..9c5e3149
--- /dev/null
+++ b/test/libsolidity/syntaxTests/controlFlow/mappingReturn/unnamed_fine.sol
@@ -0,0 +1,5 @@
+contract C {
+ mapping(uint=>uint) m;
+ function f() internal view returns (mapping(uint=>uint) storage) { return m; }
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/conversion/conversion_to_bytes.sol b/test/libsolidity/syntaxTests/conversion/conversion_to_bytes.sol
new file mode 100644
index 00000000..5946e921
--- /dev/null
+++ b/test/libsolidity/syntaxTests/conversion/conversion_to_bytes.sol
@@ -0,0 +1,5 @@
+contract test {
+ function f() public pure returns (bytes) {
+ return bytes("abc");
+ }
+}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/161_warns_assigning_decimal_to_bytesxx.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/161_warns_assigning_decimal_to_bytesxx.sol
deleted file mode 100644
index 957322af..00000000
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/161_warns_assigning_decimal_to_bytesxx.sol
+++ /dev/null
@@ -1,5 +0,0 @@
-contract Foo {
- bytes32 a = 7;
-}
-// ----
-// Warning: (31-32): Decimal literal assigned to bytesXX variable will be left-aligned. Use an explicit conversion to silence this warning.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/162_does_not_warn_assigning_hex_number_to_bytesxx.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/162_does_not_warn_assigning_hex_number_to_bytesxx.sol
deleted file mode 100644
index bc32580a..00000000
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/162_does_not_warn_assigning_hex_number_to_bytesxx.sol
+++ /dev/null
@@ -1,3 +0,0 @@
-contract Foo {
- bytes32 a = 0x1234;
-}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/163_explicit_conversion_from_decimal_to_bytesxx.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/163_explicit_conversion_from_decimal_to_bytesxx.sol
deleted file mode 100644
index af921869..00000000
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/163_explicit_conversion_from_decimal_to_bytesxx.sol
+++ /dev/null
@@ -1,3 +0,0 @@
-contract Foo {
- bytes32 a = bytes32(7);
-}
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/186_invalid_utf8_explicit.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/186_invalid_utf8_explicit.sol
index 401c46e2..0f67460f 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/186_invalid_utf8_explicit.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/186_invalid_utf8_explicit.sol
@@ -2,4 +2,4 @@ contract C {
string s = string("\xa0\x00");
}
// ----
-// TypeError: (28-46): Explicit type conversion not allowed from "literal_string (contains invalid UTF-8 sequence at position 0)" to "string storage pointer".
+// TypeError: (28-46): Explicit type conversion not allowed from "literal_string (contains invalid UTF-8 sequence at position 0)" to "string memory".
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/419_interface_structs.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/419_interface_structs.sol
index c74d52d3..385ed18e 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/419_interface_structs.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/419_interface_structs.sol
@@ -1,9 +1,6 @@
interface I {
struct A {
- // This is currently expected to break, but it *may* change in the future.
int dummy;
}
}
// ----
-// TypeError: (18-136): Structs cannot be defined in interfaces.
-// TypeError: (120-129): Variables cannot be declared in interfaces.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/482_explicit_literal_to_unspecified_string.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/482_explicit_literal_to_unspecified_string.sol
index a83eee72..c44fab55 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/482_explicit_literal_to_unspecified_string.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/482_explicit_literal_to_unspecified_string.sol
@@ -4,4 +4,4 @@ contract C {
}
}
// ----
-// TypeError: (52-65): Explicit type conversion not allowed from "literal_string "abc"" to "string storage pointer".
+// Warning: (52-65): Statement has no effect.
diff --git a/test/libsolidity/syntaxTests/types/bytesm.sol b/test/libsolidity/syntaxTests/types/bytesm.sol
index 550760b9..77ff7524 100644
--- a/test/libsolidity/syntaxTests/types/bytesm.sol
+++ b/test/libsolidity/syntaxTests/types/bytesm.sol
@@ -1,5 +1,5 @@
contract C {
- byte b = byte(1);
+ byte b = byte(0x01);
bytes1 b1 = b;
bytes2 b2 = b1;
bytes3 b3 = b2;
diff --git a/test/libsolidity/syntaxTests/types/decimal_literal_to_bytesXX_explicit.sol b/test/libsolidity/syntaxTests/types/decimal_literal_to_bytesXX_explicit.sol
new file mode 100644
index 00000000..ff285a07
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/decimal_literal_to_bytesXX_explicit.sol
@@ -0,0 +1,23 @@
+contract C {
+ function f() public pure {
+ bytes1 b1 = bytes1(1);
+ bytes2 b2 = bytes2(1);
+ bytes2 b3 = bytes2(256);
+ bytes3 b4 = bytes3(1);
+ bytes3 b5 = bytes3(65536);
+ bytes4 b6 = bytes4(1);
+ bytes4 b7 = bytes4(16777216);
+ bytes16 b8 = bytes16(1);
+ bytes32 b9 = bytes32(1);
+ }
+}
+// ----
+// TypeError: (60-69): Explicit type conversion not allowed from "int_const 1" to "bytes1".
+// TypeError: (88-97): Explicit type conversion not allowed from "int_const 1" to "bytes2".
+// TypeError: (116-127): Explicit type conversion not allowed from "int_const 256" to "bytes2".
+// TypeError: (146-155): Explicit type conversion not allowed from "int_const 1" to "bytes3".
+// TypeError: (174-187): Explicit type conversion not allowed from "int_const 65536" to "bytes3".
+// TypeError: (206-215): Explicit type conversion not allowed from "int_const 1" to "bytes4".
+// TypeError: (234-250): Explicit type conversion not allowed from "int_const 16777216" to "bytes4".
+// TypeError: (270-280): Explicit type conversion not allowed from "int_const 1" to "bytes16".
+// TypeError: (300-310): Explicit type conversion not allowed from "int_const 1" to "bytes32".
diff --git a/test/libsolidity/syntaxTests/types/decimal_literal_to_bytesXX_implicit.sol b/test/libsolidity/syntaxTests/types/decimal_literal_to_bytesXX_implicit.sol
new file mode 100644
index 00000000..e472c43b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/decimal_literal_to_bytesXX_implicit.sol
@@ -0,0 +1,23 @@
+contract C {
+ function f() public pure {
+ bytes1 b1 = 1;
+ bytes2 b2 = 1;
+ bytes2 b3 = 256;
+ bytes3 b4 = 1;
+ bytes3 b5 = 65536;
+ bytes4 b6 = 1;
+ bytes4 b7 = 16777216;
+ bytes16 b8 = 1;
+ bytes32 b9 = 1;
+ }
+}
+// ----
+// TypeError: (48-61): Type int_const 1 is not implicitly convertible to expected type bytes1.
+// TypeError: (68-81): Type int_const 1 is not implicitly convertible to expected type bytes2.
+// TypeError: (88-103): Type int_const 256 is not implicitly convertible to expected type bytes2.
+// TypeError: (110-123): Type int_const 1 is not implicitly convertible to expected type bytes3.
+// TypeError: (130-147): Type int_const 65536 is not implicitly convertible to expected type bytes3.
+// TypeError: (154-167): Type int_const 1 is not implicitly convertible to expected type bytes4.
+// TypeError: (174-194): Type int_const 16777216 is not implicitly convertible to expected type bytes4.
+// TypeError: (201-215): Type int_const 1 is not implicitly convertible to expected type bytes16.
+// TypeError: (222-236): Type int_const 1 is not implicitly convertible to expected type bytes32.
diff --git a/test/libsolidity/syntaxTests/types/hex_literal_to_bytesXX_different_size_explicit.sol b/test/libsolidity/syntaxTests/types/hex_literal_to_bytesXX_different_size_explicit.sol
new file mode 100644
index 00000000..e1e9850d
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/hex_literal_to_bytesXX_different_size_explicit.sol
@@ -0,0 +1,31 @@
+contract C {
+ function f() public pure {
+ bytes1 b1 = bytes1(0x1);
+ bytes1 b2 = bytes1(0x100);
+ bytes2 b3 = bytes2(0xFF);
+ bytes2 b4 = bytes2(0x100);
+ bytes2 b5 = bytes2(0x10000);
+ bytes3 b6 = bytes3(0xFFFF);
+ bytes3 b7 = bytes3(0x10000);
+ bytes3 b8 = bytes3(0x1000000);
+ bytes4 b9 = bytes4(0xFFFFFF);
+ bytes4 b10 = bytes4(0x1000000);
+ bytes4 b11 = bytes4(0x100000000);
+ bytes16 b12 = bytes16(0x1);
+ bytes32 b13 = bytes32(0x1);
+ }
+}
+// ----
+// TypeError: (60-71): Explicit type conversion not allowed from "int_const 1" to "bytes1".
+// TypeError: (90-103): Explicit type conversion not allowed from "int_const 256" to "bytes1".
+// TypeError: (122-134): Explicit type conversion not allowed from "int_const 255" to "bytes2".
+// TypeError: (153-166): Explicit type conversion not allowed from "int_const 256" to "bytes2".
+// TypeError: (185-200): Explicit type conversion not allowed from "int_const 65536" to "bytes2".
+// TypeError: (219-233): Explicit type conversion not allowed from "int_const 65535" to "bytes3".
+// TypeError: (252-267): Explicit type conversion not allowed from "int_const 65536" to "bytes3".
+// TypeError: (286-303): Explicit type conversion not allowed from "int_const 16777216" to "bytes3".
+// TypeError: (322-338): Explicit type conversion not allowed from "int_const 16777215" to "bytes4".
+// TypeError: (358-375): Explicit type conversion not allowed from "int_const 16777216" to "bytes4".
+// TypeError: (395-414): Explicit type conversion not allowed from "int_const 4294967296" to "bytes4".
+// TypeError: (435-447): Explicit type conversion not allowed from "int_const 1" to "bytes16".
+// TypeError: (468-480): Explicit type conversion not allowed from "int_const 1" to "bytes32".
diff --git a/test/libsolidity/syntaxTests/types/hex_literal_to_bytesXX_different_size_implicit.sol b/test/libsolidity/syntaxTests/types/hex_literal_to_bytesXX_different_size_implicit.sol
new file mode 100644
index 00000000..44ed9318
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/hex_literal_to_bytesXX_different_size_implicit.sol
@@ -0,0 +1,31 @@
+contract C {
+ function f() public pure {
+ bytes1 b1 = 0x1;
+ bytes1 b2 = 0x100;
+ bytes2 b3 = 0xFF;
+ bytes2 b4 = 0x100;
+ bytes2 b5 = 0x10000;
+ bytes3 b6 = 0xFFFF;
+ bytes3 b7 = 0x10000;
+ bytes3 b8 = 0x1000000;
+ bytes4 b9 = 0xFFFFFF;
+ bytes4 b10 = 0x1000000;
+ bytes4 b11 = 0x100000000;
+ bytes16 b12 = 0x1;
+ bytes32 b13 = 0x1;
+ }
+}
+// ----
+// TypeError: (48-63): Type int_const 1 is not implicitly convertible to expected type bytes1.
+// TypeError: (70-87): Type int_const 256 is not implicitly convertible to expected type bytes1.
+// TypeError: (94-110): Type int_const 255 is not implicitly convertible to expected type bytes2.
+// TypeError: (117-134): Type int_const 256 is not implicitly convertible to expected type bytes2.
+// TypeError: (141-160): Type int_const 65536 is not implicitly convertible to expected type bytes2.
+// TypeError: (167-185): Type int_const 65535 is not implicitly convertible to expected type bytes3.
+// TypeError: (192-211): Type int_const 65536 is not implicitly convertible to expected type bytes3.
+// TypeError: (218-239): Type int_const 16777216 is not implicitly convertible to expected type bytes3.
+// TypeError: (246-266): Type int_const 16777215 is not implicitly convertible to expected type bytes4.
+// TypeError: (273-295): Type int_const 16777216 is not implicitly convertible to expected type bytes4.
+// TypeError: (302-326): Type int_const 4294967296 is not implicitly convertible to expected type bytes4.
+// TypeError: (333-350): Type int_const 1 is not implicitly convertible to expected type bytes16.
+// TypeError: (357-374): Type int_const 1 is not implicitly convertible to expected type bytes32.
diff --git a/test/libsolidity/syntaxTests/types/hex_literal_to_bytesXX_same_size_explicit.sol b/test/libsolidity/syntaxTests/types/hex_literal_to_bytesXX_same_size_explicit.sol
new file mode 100644
index 00000000..4e18640c
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/hex_literal_to_bytesXX_same_size_explicit.sol
@@ -0,0 +1,13 @@
+contract C {
+ function f() public pure {
+ bytes1 b1 = bytes1(0x01);
+ bytes1 b2 = bytes1(0xFF);
+ bytes2 b3 = bytes2(0x0100);
+ bytes2 b4 = bytes2(0xFFFF);
+ bytes3 b5 = bytes3(0x010000);
+ bytes3 b6 = bytes3(0xFFFFFF);
+ bytes4 b7 = bytes4(0x01000000);
+ bytes4 b8 = bytes4(0xFFFFFFFF);
+ b1; b2; b3; b4; b5; b6; b7; b8;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/types/hex_literal_to_bytesXX_same_size_implicit.sol b/test/libsolidity/syntaxTests/types/hex_literal_to_bytesXX_same_size_implicit.sol
new file mode 100644
index 00000000..daf0bf56
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/hex_literal_to_bytesXX_same_size_implicit.sol
@@ -0,0 +1,13 @@
+contract C {
+ function f() public pure {
+ bytes1 b1 = 0x01;
+ bytes1 b2 = 0xFF;
+ bytes2 b3 = 0x0100;
+ bytes2 b4 = 0xFFFF;
+ bytes3 b5 = 0x010000;
+ bytes3 b6 = 0xFFFFFF;
+ bytes4 b7 = 0x01000000;
+ bytes4 b8 = 0xFFFFFFFF;
+ b1; b2; b3; b4; b5; b6; b7; b8;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/types/mapping/argument_external.sol b/test/libsolidity/syntaxTests/types/mapping/argument_external.sol
new file mode 100644
index 00000000..0354893f
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/mapping/argument_external.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f(mapping(uint => uint) storage) external pure {
+ }
+}
+// ----
+// TypeError: (28-49): Type is required to live outside storage.
+// TypeError: (28-49): Internal or recursive type is not allowed for public or external functions.
diff --git a/test/libsolidity/syntaxTests/types/mapping/argument_internal.sol b/test/libsolidity/syntaxTests/types/mapping/argument_internal.sol
new file mode 100644
index 00000000..3c021515
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/mapping/argument_internal.sol
@@ -0,0 +1,5 @@
+contract C {
+ function f(mapping(uint => uint) storage) internal pure {
+ }
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/types/mapping/argument_private.sol b/test/libsolidity/syntaxTests/types/mapping/argument_private.sol
new file mode 100644
index 00000000..63733d71
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/mapping/argument_private.sol
@@ -0,0 +1,5 @@
+contract C {
+ function f(mapping(uint => uint) storage) private pure {
+ }
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/types/mapping/argument_public.sol b/test/libsolidity/syntaxTests/types/mapping/argument_public.sol
new file mode 100644
index 00000000..e4121c7f
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/mapping/argument_public.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f(mapping(uint => uint) storage) public pure {
+ }
+}
+// ----
+// TypeError: (28-49): Type is required to live outside storage.
+// TypeError: (28-49): Internal or recursive type is not allowed for public or external functions.
diff --git a/test/libsolidity/syntaxTests/types/mapping/array_argument_external.sol b/test/libsolidity/syntaxTests/types/mapping/array_argument_external.sol
new file mode 100644
index 00000000..8dea6907
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/mapping/array_argument_external.sol
@@ -0,0 +1,6 @@
+contract C {
+ function f(mapping(uint => uint)[] storage) external pure {
+ }
+}
+// ----
+// TypeError: (28-51): Location has to be calldata for external functions (remove the "memory" or "storage" keyword).
diff --git a/test/libsolidity/syntaxTests/types/mapping/array_argument_internal.sol b/test/libsolidity/syntaxTests/types/mapping/array_argument_internal.sol
new file mode 100644
index 00000000..352d0982
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/mapping/array_argument_internal.sol
@@ -0,0 +1,5 @@
+contract C {
+ function f(mapping(uint => uint)[] storage) internal pure {
+ }
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/types/mapping/array_argument_private.sol b/test/libsolidity/syntaxTests/types/mapping/array_argument_private.sol
new file mode 100644
index 00000000..332dbe6c
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/mapping/array_argument_private.sol
@@ -0,0 +1,5 @@
+contract C {
+ function f(mapping(uint => uint)[] storage) private pure {
+ }
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/types/mapping/array_argument_public.sol b/test/libsolidity/syntaxTests/types/mapping/array_argument_public.sol
new file mode 100644
index 00000000..69dcec01
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/mapping/array_argument_public.sol
@@ -0,0 +1,6 @@
+contract C {
+ function f(mapping(uint => uint)[] storage) public pure {
+ }
+}
+// ----
+// TypeError: (28-51): Location has to be memory for publicly visible functions (remove the "storage" or "calldata" keyword).
diff --git a/test/libsolidity/syntaxTests/types/mapping/function_type_argument_external.sol b/test/libsolidity/syntaxTests/types/mapping/function_type_argument_external.sol
new file mode 100644
index 00000000..7fe74fb6
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/mapping/function_type_argument_external.sol
@@ -0,0 +1,6 @@
+contract C {
+ function f(function(mapping(uint=>uint) storage) external) public pure {
+ }
+}
+// ----
+// TypeError: (37-56): Internal type cannot be used for external function type.
diff --git a/test/libsolidity/syntaxTests/types/mapping/function_type_argument_internal.sol b/test/libsolidity/syntaxTests/types/mapping/function_type_argument_internal.sol
new file mode 100644
index 00000000..01e2322e
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/mapping/function_type_argument_internal.sol
@@ -0,0 +1,4 @@
+contract C {
+ function f(function(mapping(uint=>uint) storage) internal) internal pure {
+ }
+}
diff --git a/test/libsolidity/syntaxTests/types/mapping/function_type_return_external.sol b/test/libsolidity/syntaxTests/types/mapping/function_type_return_external.sol
new file mode 100644
index 00000000..f0f8dea6
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/mapping/function_type_return_external.sol
@@ -0,0 +1,6 @@
+contract C {
+ function f(function() external returns (mapping(uint=>uint) storage)) public pure {
+ }
+}
+// ----
+// TypeError: (57-76): Internal type cannot be used for external function type.
diff --git a/test/libsolidity/syntaxTests/types/mapping/function_type_return_internal.sol b/test/libsolidity/syntaxTests/types/mapping/function_type_return_internal.sol
new file mode 100644
index 00000000..bd298e5d
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/mapping/function_type_return_internal.sol
@@ -0,0 +1,4 @@
+contract C {
+ function f(function() internal returns (mapping(uint=>uint) storage)) internal pure {
+ }
+}
diff --git a/test/libsolidity/syntaxTests/types/mapping/library_argument_external.sol b/test/libsolidity/syntaxTests/types/mapping/library_argument_external.sol
new file mode 100644
index 00000000..e78c6930
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/mapping/library_argument_external.sol
@@ -0,0 +1,6 @@
+library L {
+ function f(mapping(uint => uint) storage) external pure {
+ }
+}
+// ----
+// TypeError: (27-48): Type is required to live outside storage.
diff --git a/test/libsolidity/syntaxTests/types/mapping/library_argument_internal.sol b/test/libsolidity/syntaxTests/types/mapping/library_argument_internal.sol
new file mode 100644
index 00000000..1228b6b6
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/mapping/library_argument_internal.sol
@@ -0,0 +1,4 @@
+library L {
+ function f(mapping(uint => uint) storage) internal pure {
+ }
+}
diff --git a/test/libsolidity/syntaxTests/types/mapping/library_argument_private.sol b/test/libsolidity/syntaxTests/types/mapping/library_argument_private.sol
new file mode 100644
index 00000000..5eaff16b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/mapping/library_argument_private.sol
@@ -0,0 +1,4 @@
+library L {
+ function f(mapping(uint => uint) storage) private pure {
+ }
+}
diff --git a/test/libsolidity/syntaxTests/types/mapping/library_argument_public.sol b/test/libsolidity/syntaxTests/types/mapping/library_argument_public.sol
new file mode 100644
index 00000000..56393b68
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/mapping/library_argument_public.sol
@@ -0,0 +1,6 @@
+library L {
+ function f(mapping(uint => uint) storage) public pure {
+ }
+}
+// ----
+// TypeError: (27-48): Type is required to live outside storage.
diff --git a/test/libsolidity/syntaxTests/types/mapping/library_array_argument_external.sol b/test/libsolidity/syntaxTests/types/mapping/library_array_argument_external.sol
new file mode 100644
index 00000000..f5691675
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/mapping/library_array_argument_external.sol
@@ -0,0 +1,6 @@
+library L {
+ function f(mapping(uint => uint)[] storage) external pure {
+ }
+}
+// ----
+// TypeError: (27-50): Type is required to live outside storage.
diff --git a/test/libsolidity/syntaxTests/types/mapping/library_array_argument_internal.sol b/test/libsolidity/syntaxTests/types/mapping/library_array_argument_internal.sol
new file mode 100644
index 00000000..55c1cea0
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/mapping/library_array_argument_internal.sol
@@ -0,0 +1,4 @@
+library L {
+ function f(mapping(uint => uint)[] storage) internal pure {
+ }
+}
diff --git a/test/libsolidity/syntaxTests/types/mapping/library_array_argument_private.sol b/test/libsolidity/syntaxTests/types/mapping/library_array_argument_private.sol
new file mode 100644
index 00000000..d37d6504
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/mapping/library_array_argument_private.sol
@@ -0,0 +1,4 @@
+library L {
+ function f(mapping(uint => uint)[] storage) private pure {
+ }
+}
diff --git a/test/libsolidity/syntaxTests/types/mapping/library_array_argument_public.sol b/test/libsolidity/syntaxTests/types/mapping/library_array_argument_public.sol
new file mode 100644
index 00000000..bb06d4bc
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/mapping/library_array_argument_public.sol
@@ -0,0 +1,6 @@
+library L {
+ function f(mapping(uint => uint)[] storage) public pure {
+ }
+}
+// ----
+// TypeError: (27-50): Type is required to live outside storage.
diff --git a/test/libsolidity/syntaxTests/types/mapping/library_return_external.sol b/test/libsolidity/syntaxTests/types/mapping/library_return_external.sol
new file mode 100644
index 00000000..a3bb1c32
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/mapping/library_return_external.sol
@@ -0,0 +1,10 @@
+library L
+{
+ function f(mapping(uint => uint) storage a, mapping(uint => uint) storage b, bool c) external pure returns(mapping(uint => uint) storage) {
+ return c ? a : b;
+ }
+}
+// ----
+// TypeError: (27-58): Type is required to live outside storage.
+// TypeError: (60-91): Type is required to live outside storage.
+// TypeError: (123-144): Type is required to live outside storage.
diff --git a/test/libsolidity/syntaxTests/types/mapping/library_return_internal.sol b/test/libsolidity/syntaxTests/types/mapping/library_return_internal.sol
new file mode 100644
index 00000000..d0fca6bf
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/mapping/library_return_internal.sol
@@ -0,0 +1,6 @@
+library L
+{
+ function f(mapping(uint => uint) storage a, mapping(uint => uint) storage b, bool c) internal pure returns(mapping(uint => uint) storage) {
+ return c ? a : b;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/types/mapping/library_return_private.sol b/test/libsolidity/syntaxTests/types/mapping/library_return_private.sol
new file mode 100644
index 00000000..13c2000f
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/mapping/library_return_private.sol
@@ -0,0 +1,6 @@
+library L
+{
+ function f(mapping(uint => uint) storage a, mapping(uint => uint) storage b, bool c) private pure returns(mapping(uint => uint) storage) {
+ return c ? a : b;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/types/mapping/library_return_public.sol b/test/libsolidity/syntaxTests/types/mapping/library_return_public.sol
new file mode 100644
index 00000000..ac52d677
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/mapping/library_return_public.sol
@@ -0,0 +1,10 @@
+library L
+{
+ function f(mapping(uint => uint) storage a, mapping(uint => uint) storage b, bool c) public pure returns(mapping(uint => uint) storage) {
+ return c ? a : b;
+ }
+}
+// ----
+// TypeError: (27-58): Type is required to live outside storage.
+// TypeError: (60-91): Type is required to live outside storage.
+// TypeError: (121-142): Type is required to live outside storage.
diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_array_return_external.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_array_return_external.sol
new file mode 100644
index 00000000..dbe030fb
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/mapping/mapping_array_return_external.sol
@@ -0,0 +1,6 @@
+contract C {
+ function f() external pure returns (mapping(uint=>uint)[] storage m) {
+ }
+}
+// ----
+// TypeError: (53-84): Location has to be memory for publicly visible functions (remove the "storage" or "calldata" keyword).
diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_array_return_internal.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_array_return_internal.sol
new file mode 100644
index 00000000..8837c745
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/mapping/mapping_array_return_internal.sol
@@ -0,0 +1,16 @@
+contract C {
+ mapping(uint=>uint)[] m;
+ function f() internal view returns (mapping(uint=>uint)[] storage) {
+ return m;
+ }
+ function g() private view returns (mapping(uint=>uint)[] storage) {
+ return m;
+ }
+ function h() internal view returns (mapping(uint=>uint)[] storage r) {
+ r = m;
+ }
+ function i() private view returns (mapping(uint=>uint)[] storage r) {
+ (r,r) = (m,m);
+ }
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_array_return_public.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_array_return_public.sol
new file mode 100644
index 00000000..7dfecf19
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/mapping/mapping_array_return_public.sol
@@ -0,0 +1,6 @@
+contract C {
+ function f() public pure returns (mapping(uint=>uint)[] storage m) {
+ }
+}
+// ----
+// TypeError: (51-82): Location has to be memory for publicly visible functions (remove the "storage" or "calldata" keyword).
diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_return_internal.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_return_internal.sol
index a46003f8..4912836e 100644
--- a/test/libsolidity/syntaxTests/types/mapping/mapping_return_internal.sol
+++ b/test/libsolidity/syntaxTests/types/mapping/mapping_return_internal.sol
@@ -1,4 +1,3 @@
-// This should be allowed in a future release.
contract C {
mapping(uint=>uint) m;
function f() internal view returns (mapping(uint=>uint) storage) {
@@ -15,7 +14,3 @@ contract C {
}
}
// ----
-// TypeError: (127-146): Type is required to live outside storage.
-// TypeError: (221-240): Type is required to live outside storage.
-// TypeError: (316-345): Type is required to live outside storage.
-// TypeError: (409-438): Type is required to live outside storage.
diff --git a/test/libsolidity/syntaxTests/types/zero_literal_to_bytesXX_explicit.sol b/test/libsolidity/syntaxTests/types/zero_literal_to_bytesXX_explicit.sol
new file mode 100644
index 00000000..5d606089
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/zero_literal_to_bytesXX_explicit.sol
@@ -0,0 +1,30 @@
+contract C {
+ function f() public pure {
+ bytes1 b1 = bytes1(0);
+ bytes2 b2 = bytes2(0);
+ bytes3 b3 = bytes3(0);
+ bytes4 b4 = bytes4(0);
+ bytes8 b8 = bytes8(0);
+ bytes16 b16 = bytes16(0);
+ bytes32 b32 = bytes32(0);
+ b1; b2; b3; b4; b8; b16; b32;
+ }
+ function g() public pure {
+ bytes1 b1 = bytes1(0x000);
+ bytes2 b2 = bytes2(0x00000);
+ bytes3 b3 = bytes3(0x0000000);
+ bytes4 b4 = bytes4(0x000000000);
+ bytes8 b8 = bytes8(0x00000000000000000);
+ b1; b2; b3; b4; b8;
+ }
+ function h() public pure {
+ bytes1 b1 = bytes1(0x0);
+ bytes2 b2 = bytes2(0x0);
+ bytes3 b3 = bytes3(0x0);
+ bytes4 b4 = bytes4(0x0);
+ bytes8 b8 = bytes8(0x0);
+ bytes16 b16 = bytes16(0x0);
+ bytes32 b32 = bytes32(0x0);
+ b1; b2; b3; b4; b8; b16; b32;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/types/zero_literal_to_bytesXX_implicit.sol b/test/libsolidity/syntaxTests/types/zero_literal_to_bytesXX_implicit.sol
new file mode 100644
index 00000000..48be0655
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/zero_literal_to_bytesXX_implicit.sol
@@ -0,0 +1,30 @@
+contract C {
+ function f() public pure {
+ bytes1 b1 = 0;
+ bytes2 b2 = 0;
+ bytes3 b3 = 0;
+ bytes4 b4 = 0;
+ bytes8 b8 = 0;
+ bytes16 b16 = 0;
+ bytes32 b32 = 0;
+ b1; b2; b3; b4; b8; b16; b32;
+ }
+ function g() public pure {
+ bytes1 b1 = 0x000;
+ bytes2 b2 = 0x00000;
+ bytes3 b3 = 0x0000000;
+ bytes4 b4 = 0x000000000;
+ bytes8 b8 = 0x00000000000000000;
+ b1; b2; b3; b4; b8;
+ }
+ function h() public pure {
+ bytes1 b1 = 0x0;
+ bytes2 b2 = 0x0;
+ bytes3 b3 = 0x0;
+ bytes4 b4 = 0x0;
+ bytes8 b8 = 0x0;
+ bytes16 b16 = 0x0;
+ bytes32 b32 = 0x0;
+ b1; b2; b3; b4; b8; b16; b32;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions.sol b/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions.sol
index 51e36a58..2cb185c9 100644
--- a/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions.sol
+++ b/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions.sol
@@ -9,7 +9,7 @@ contract C {
function g() pure public {
bytes32 x = keccak256("abc");
bytes32 y = sha256("abc");
- address z = ecrecover(bytes32(1), uint8(2), bytes32(3), bytes32(4));
+ address z = ecrecover(bytes32(uint256(1)), uint8(2), bytes32(uint256(3)), bytes32(uint256(4)));
require(true);
assert(true);
x; y; z;
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions_restrict_warning.sol b/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions_restrict_warning.sol
index 0b834022..4a651d21 100644
--- a/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions_restrict_warning.sol
+++ b/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions_restrict_warning.sol
@@ -2,7 +2,7 @@ contract C {
function f() view public {
bytes32 x = keccak256("abc");
bytes32 y = sha256("abc");
- address z = ecrecover(bytes32(1), uint8(2), bytes32(3), bytes32(4));
+ address z = ecrecover(bytes32(uint256(1)), uint8(2), bytes32(uint256(3)), bytes32(uint256(4)));
require(true);
assert(true);
x; y; z;
@@ -10,12 +10,12 @@ contract C {
function g() public {
bytes32 x = keccak256("abc");
bytes32 y = sha256("abc");
- address z = ecrecover(bytes32(1), uint8(2), bytes32(3), bytes32(4));
+ address z = ecrecover(bytes32(uint256(1)), uint8(2), bytes32(uint256(3)), bytes32(uint256(4)));
require(true);
assert(true);
x; y; z;
}
}
// ----
-// Warning: (17-261): Function state mutability can be restricted to pure
-// Warning: (266-505): Function state mutability can be restricted to pure
+// Warning: (17-288): Function state mutability can be restricted to pure
+// Warning: (293-559): Function state mutability can be restricted to pure