diff options
Diffstat (limited to 'test')
40 files changed, 233 insertions, 118 deletions
diff --git a/test/libsolidity/SolidityABIJSON.cpp b/test/libsolidity/SolidityABIJSON.cpp index f2d6d66f..0b2e23e6 100644 --- a/test/libsolidity/SolidityABIJSON.cpp +++ b/test/libsolidity/SolidityABIJSON.cpp @@ -980,6 +980,7 @@ BOOST_AUTO_TEST_CASE(return_structs_with_contracts) BOOST_AUTO_TEST_CASE(event_structs) { char const* text = R"( + pragma experimental ABIEncoderV2; contract C { struct S { uint a; T[] sub; bytes b; } struct T { uint[2] x; } diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 45a56b22..9c287e5e 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -1478,6 +1478,73 @@ BOOST_AUTO_TEST_CASE(multi_level_mapping) testContractAgainstCpp("f(uint256,uint256,uint256)", f, u256(5), u256(4), u256(0)); } +BOOST_AUTO_TEST_CASE(mapping_local_assignment) +{ + char const* sourceCode = R"( + contract test { + mapping(uint8 => uint8) m1; + mapping(uint8 => uint8) m2; + function f() public returns (uint8, uint8, uint8, uint8) { + mapping(uint8 => uint8) storage m = m1; + m[1] = 42; + + m = m2; + m[2] = 21; + + return (m1[1], m1[2], m2[1], m2[2]); + } + } + )"; + compileAndRun(sourceCode); + + ABI_CHECK(callContractFunction("f()"), encodeArgs(byte(42), byte(0), byte(0), byte(21))); +} + +BOOST_AUTO_TEST_CASE(mapping_local_tuple_assignment) +{ + char const* sourceCode = R"( + contract test { + mapping(uint8 => uint8) m1; + mapping(uint8 => uint8) m2; + function f() public returns (uint8, uint8, uint8, uint8) { + mapping(uint8 => uint8) storage m = m1; + m[1] = 42; + + uint8 v; + (m, v) = (m2, 21); + m[2] = v; + + return (m1[1], m1[2], m2[1], m2[2]); + } + } + )"; + compileAndRun(sourceCode); + + ABI_CHECK(callContractFunction("f()"), encodeArgs(byte(42), byte(0), byte(0), byte(21))); +} + +BOOST_AUTO_TEST_CASE(mapping_local_compound_assignment) +{ + char const* sourceCode = R"( + contract test { + mapping(uint8 => uint8) m1; + mapping(uint8 => uint8) m2; + function f() public returns (uint8, uint8, uint8, uint8) { + mapping(uint8 => uint8) storage m = m1; + m[1] = 42; + + (m = m2)[2] = 21; + + return (m1[1], m1[2], m2[1], m2[2]); + } + } + )"; + compileAndRun(sourceCode); + + ABI_CHECK(callContractFunction("f()"), encodeArgs(byte(42), byte(0), byte(0), byte(21))); +} + + BOOST_AUTO_TEST_CASE(structs) { char const* sourceCode = R"( @@ -12422,6 +12489,44 @@ BOOST_AUTO_TEST_CASE(abi_encode_with_signaturev2) ABI_CHECK(callContractFunction("f4()"), expectation); } +BOOST_AUTO_TEST_CASE(abi_encode_empty_string) +{ + char const* sourceCode = R"( + // Tests that this will not end up using a "bytes0" type + // (which would assert) + contract C { + function f() public pure returns (bytes memory, bytes memory) { + return (abi.encode(""), abi.encodePacked("")); + } + } + )"; + compileAndRun(sourceCode, 0, "C"); + ABI_CHECK(callContractFunction("f()"), encodeArgs( + 0x40, 0xc0, + 0x60, 0x20, 0x00, 0x00, + 0x00 + )); +} + +BOOST_AUTO_TEST_CASE(abi_encode_empty_string_v2) +{ + char const* sourceCode = R"( + // Tests that this will not end up using a "bytes0" type + // (which would assert) + pragma experimental ABIEncoderV2; + contract C { + function f() public pure returns (bytes memory, bytes memory) { + return (abi.encode(""), abi.encodePacked("")); + } + } + )"; + compileAndRun(sourceCode, 0, "C"); + ABI_CHECK(callContractFunction("f()"), encodeArgs( + 0x40, 0xa0, + 0x40, 0x20, 0x00, + 0x00 + )); +} BOOST_AUTO_TEST_CASE(abi_encode_call) { char const* sourceCode = R"T( diff --git a/test/libsolidity/syntaxTests/constants/assign_constant_function_value_050.sol b/test/libsolidity/syntaxTests/constants/assign_constant_function_value_050.sol deleted file mode 100644 index 2c92899d..00000000 --- a/test/libsolidity/syntaxTests/constants/assign_constant_function_value_050.sol +++ /dev/null @@ -1,8 +0,0 @@ -pragma experimental "v0.5.0"; - -contract C { - function () pure returns (uint) x; - uint constant y = x(); -} -// ---- -// TypeError: (105-108): Initial value for constant variable has to be compile-time constant. diff --git a/test/libsolidity/syntaxTests/emit_empty.sol b/test/libsolidity/syntaxTests/emit/emit_empty.sol index 819d88fe..819d88fe 100644 --- a/test/libsolidity/syntaxTests/emit_empty.sol +++ b/test/libsolidity/syntaxTests/emit/emit_empty.sol diff --git a/test/libsolidity/syntaxTests/emit_non_event.sol b/test/libsolidity/syntaxTests/emit/emit_non_event.sol index d5045ddf..d5045ddf 100644 --- a/test/libsolidity/syntaxTests/emit_non_event.sol +++ b/test/libsolidity/syntaxTests/emit/emit_non_event.sol diff --git a/test/libsolidity/syntaxTests/events/event_nested_array.sol b/test/libsolidity/syntaxTests/events/event_nested_array.sol new file mode 100644 index 00000000..70af63b6 --- /dev/null +++ b/test/libsolidity/syntaxTests/events/event_nested_array.sol @@ -0,0 +1,5 @@ +contract c { + event E(uint[][]); +} +// ---- +// TypeError: (25-33): This type is only supported in the new experimental ABI encoder. Use "pragma experimental ABIEncoderV2;" to enable the feature. diff --git a/test/libsolidity/syntaxTests/events/event_nested_array_2.sol b/test/libsolidity/syntaxTests/events/event_nested_array_2.sol new file mode 100644 index 00000000..5825650e --- /dev/null +++ b/test/libsolidity/syntaxTests/events/event_nested_array_2.sol @@ -0,0 +1,4 @@ +contract c { + event E(uint[2][]); +} +// ---- diff --git a/test/libsolidity/syntaxTests/events/event_nested_array_in_struct.sol b/test/libsolidity/syntaxTests/events/event_nested_array_in_struct.sol new file mode 100644 index 00000000..fd59e962 --- /dev/null +++ b/test/libsolidity/syntaxTests/events/event_nested_array_in_struct.sol @@ -0,0 +1,6 @@ +contract c { + struct S { uint x; uint[][] arr; } + event E(S); +} +// ---- +// TypeError: (61-62): This type is only supported in the new experimental ABI encoder. Use "pragma experimental ABIEncoderV2;" to enable the feature. diff --git a/test/libsolidity/syntaxTests/events/event_struct.sol b/test/libsolidity/syntaxTests/events/event_struct.sol new file mode 100644 index 00000000..c955dc5e --- /dev/null +++ b/test/libsolidity/syntaxTests/events/event_struct.sol @@ -0,0 +1,6 @@ +contract c { + struct S { uint a ; } + event E(S); +} +// ---- +// TypeError: (51-52): This type is only supported in the new experimental ABI encoder. Use "pragma experimental ABIEncoderV2;" to enable the feature. diff --git a/test/libsolidity/syntaxTests/events/event_struct_indexed.sol b/test/libsolidity/syntaxTests/events/event_struct_indexed.sol new file mode 100644 index 00000000..69ee5017 --- /dev/null +++ b/test/libsolidity/syntaxTests/events/event_struct_indexed.sol @@ -0,0 +1,6 @@ +contract c { + struct S { uint a ; } + event E(S indexed); +} +// ---- +// TypeError: (51-52): This type is only supported in the new experimental ABI encoder. Use "pragma experimental ABIEncoderV2;" to enable the feature. diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor_V050.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor_V050.sol deleted file mode 100644 index 8d5df5bf..00000000 --- a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor_V050.sol +++ /dev/null @@ -1,7 +0,0 @@ -pragma experimental "v0.5.0"; - -contract A { constructor(uint) public { } } -contract B is A(2) { constructor() public { } } -contract C is B { constructor() A(3) public { } } -// ---- -// DeclarationError: (156-160): Base constructor arguments given twice. diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_V050.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_V050.sol deleted file mode 100644 index f9325f99..00000000 --- a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_V050.sol +++ /dev/null @@ -1,6 +0,0 @@ -pragma experimental "v0.5.0"; - -contract A { constructor(uint) public { } } -contract B is A(2) { constructor() A(3) public { } } -// ---- -// DeclarationError: (110-114): Base constructor arguments given twice. diff --git a/test/libsolidity/syntaxTests/modifiers/modifiers_on_abstract_functions_050.sol b/test/libsolidity/syntaxTests/modifiers/modifiers_on_abstract_functions_050.sol deleted file mode 100644 index af1babbc..00000000 --- a/test/libsolidity/syntaxTests/modifiers/modifiers_on_abstract_functions_050.sol +++ /dev/null @@ -1,10 +0,0 @@ -pragma experimental "v0.5.0"; -contract C -{ - modifier only_owner() { _; } - function foo() only_owner public; - function bar() public only_owner; -} -// ---- -// SyntaxError: (80-113): Functions without implementation cannot have modifiers. -// SyntaxError: (118-151): Functions without implementation cannot have modifiers. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/016_assignment_to_mapping.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/016_assignment_to_mapping.sol deleted file mode 100644 index 27b1ea96..00000000 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/016_assignment_to_mapping.sol +++ /dev/null @@ -1,12 +0,0 @@ -contract test { - struct str { - mapping(uint=>uint) map; - } - str data; - function fun() public { - mapping(uint=>uint) storage a = data.map; - data.map = a; - } -} -// ---- -// TypeError: (172-184): Mappings cannot be assigned to. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/166_assigning_state_to_const_variable_050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/166_assigning_state_to_const_variable_050.sol deleted file mode 100644 index dc0a6e63..00000000 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/166_assigning_state_to_const_variable_050.sol +++ /dev/null @@ -1,7 +0,0 @@ -pragma experimental "v0.5.0"; - -contract C { - address constant x = msg.sender; -} -// ---- -// TypeError: (69-79): Initial value for constant variable has to be compile-time constant. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/352_callcode_deprecated_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/352_callcode_deprecated_v050.sol deleted file mode 100644 index c0e29b38..00000000 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/352_callcode_deprecated_v050.sol +++ /dev/null @@ -1,8 +0,0 @@ -pragma experimental "v0.5.0"; -contract test { - function f() pure public { - address(0x12).callcode; - } -} -// ---- -// TypeError: (85-107): "callcode" has been deprecated in favour of "delegatecall". diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/375_inline_assembly_unbalanced_two_stack_load.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/375_inline_assembly_unbalanced_two_stack_load.sol index 4cda64e7..ca1e15a9 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/375_inline_assembly_unbalanced_two_stack_load.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/375_inline_assembly_unbalanced_two_stack_load.sol @@ -1,4 +1,3 @@ -pragma experimental "v0.5.0"; contract c { uint8 x; function f() public { @@ -6,4 +5,4 @@ contract c { } } // ---- -// TypeError: (105-106): Only local variables are supported. To access storage variables, use the _slot and _offset suffixes. +// TypeError: (75-76): Only local variables are supported. To access storage variables, use the _slot and _offset suffixes. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/376_inline_assembly_in_modifier.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/376_inline_assembly_in_modifier.sol index d6dcc4d0..0032f99e 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/376_inline_assembly_in_modifier.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/376_inline_assembly_in_modifier.sol @@ -1,4 +1,3 @@ -pragma experimental "v0.5.0"; contract test { modifier m { uint a = 1; @@ -11,4 +10,4 @@ contract test { } } // ---- -// Warning: (152-181): Function state mutability can be restricted to pure +// Warning: (122-151): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/377_inline_assembly_storage.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/377_inline_assembly_storage.sol index 9a2065e2..3dfb458a 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/377_inline_assembly_storage.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/377_inline_assembly_storage.sol @@ -1,4 +1,3 @@ -pragma experimental "v0.5.0"; contract test { uint x = 1; function f() public { @@ -8,4 +7,4 @@ contract test { } } // ---- -// TypeError: (119-120): Only local variables are supported. To access storage variables, use the _slot and _offset suffixes. +// TypeError: (89-90): Only local variables are supported. To access storage variables, use the _slot and _offset suffixes. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/378_inline_assembly_storage_in_modifiers.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/378_inline_assembly_storage_in_modifiers.sol index b99179ef..b9b92d47 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/378_inline_assembly_storage_in_modifiers.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/378_inline_assembly_storage_in_modifiers.sol @@ -1,4 +1,3 @@ -pragma experimental "v0.5.0"; contract test { uint x = 1; modifier m { @@ -11,4 +10,4 @@ contract test { } } // ---- -// TypeError: (110-111): Only local variables are supported. To access storage variables, use the _slot and _offset suffixes. +// TypeError: (80-81): Only local variables are supported. To access storage variables, use the _slot and _offset suffixes. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/379_inline_assembly_constant_assign.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/379_inline_assembly_constant_assign.sol index 866232dd..c8928804 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/379_inline_assembly_constant_assign.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/379_inline_assembly_constant_assign.sol @@ -1,4 +1,3 @@ -pragma experimental "v0.5.0"; contract test { uint constant x = 1; function f() public { @@ -8,4 +7,4 @@ contract test { } } // ---- -// TypeError: (128-129): Constant variables not supported by inline assembly. +// TypeError: (98-99): Constant variables not supported by inline assembly. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/380_inline_assembly_constant_access.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/380_inline_assembly_constant_access.sol index a41858a0..03ff9166 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/380_inline_assembly_constant_access.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/380_inline_assembly_constant_access.sol @@ -1,4 +1,3 @@ -pragma experimental "v0.5.0"; contract test { uint constant x = 1; function f() public { @@ -8,4 +7,4 @@ contract test { } } // ---- -// TypeError: (137-138): Constant variables not supported by inline assembly. +// TypeError: (107-108): Constant variables not supported by inline assembly. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/381_inline_assembly_local_variable_access_out_of_functions.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/381_inline_assembly_local_variable_access_out_of_functions.sol index 93004ef6..877f5783 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/381_inline_assembly_local_variable_access_out_of_functions.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/381_inline_assembly_local_variable_access_out_of_functions.sol @@ -1,4 +1,3 @@ -pragma experimental "v0.5.0"; contract test { function f() public { uint a; @@ -8,4 +7,4 @@ contract test { } } // ---- -// DeclarationError: (144-145): Cannot access local Solidity variables from inside an inline assembly function. +// DeclarationError: (114-115): Cannot access local Solidity variables from inside an inline assembly function. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/382_inline_assembly_local_variable_access_out_of_functions_storage_ptr.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/382_inline_assembly_local_variable_access_out_of_functions_storage_ptr.sol index 913ea725..65d614a3 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/382_inline_assembly_local_variable_access_out_of_functions_storage_ptr.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/382_inline_assembly_local_variable_access_out_of_functions_storage_ptr.sol @@ -1,4 +1,3 @@ -pragma experimental "v0.5.0"; contract test { uint[] r; function f() public { @@ -9,4 +8,4 @@ contract test { } } // ---- -// DeclarationError: (172-180): Cannot access local Solidity variables from inside an inline assembly function. +// DeclarationError: (142-150): Cannot access local Solidity variables from inside an inline assembly function. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/383_inline_assembly_storage_variable_access_out_of_functions.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/383_inline_assembly_storage_variable_access_out_of_functions.sol index 7528f355..abe9067a 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/383_inline_assembly_storage_variable_access_out_of_functions.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/383_inline_assembly_storage_variable_access_out_of_functions.sol @@ -1,4 +1,3 @@ -pragma experimental "v0.5.0"; contract test { uint a; function f() pure public { diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/385_inline_assembly_calldata_variables.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/385_inline_assembly_calldata_variables.sol index d95fd978..9e324ce1 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/385_inline_assembly_calldata_variables.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/385_inline_assembly_calldata_variables.sol @@ -1,4 +1,3 @@ -pragma experimental "v0.5.0"; contract C { function f(bytes bytesAsCalldata) external { assembly { @@ -7,4 +6,4 @@ contract C { } } // ---- -// TypeError: (132-147): Call data elements cannot be accessed directly. Copy to a local variable first or use "calldataload" or "calldatacopy" with manually determined offsets and sizes. +// TypeError: (102-117): Call data elements cannot be accessed directly. Copy to a local variable first or use "calldataload" or "calldatacopy" with manually determined offsets and sizes. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/392_inline_assembly_050_jump.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/392_inline_assembly_050_jump.sol deleted file mode 100644 index 0c98ada1..00000000 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/392_inline_assembly_050_jump.sol +++ /dev/null @@ -1,10 +0,0 @@ -pragma experimental "v0.5.0"; -contract C { - function f() pure public { - assembly { - jump(2) - } - } -} -// ---- -// SyntaxError: (105-112): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/394_inline_assembly_050_leave_items_on_stack.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/394_inline_assembly_050_leave_items_on_stack.sol deleted file mode 100644 index f72fe741..00000000 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/394_inline_assembly_050_leave_items_on_stack.sol +++ /dev/null @@ -1,11 +0,0 @@ -pragma experimental "v0.5.0"; -contract C { - function f() pure public { - assembly { - mload(0) - } - } -} -// ---- -// SyntaxError: (105-113): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them. -// DeclarationError: (91-123): Unbalanced stack at the end of a block: 1 surplus item(s). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/564_events_without_emit_deprecated_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/564_events_without_emit_deprecated_v050.sol deleted file mode 100644 index e148d65a..00000000 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/564_events_without_emit_deprecated_v050.sol +++ /dev/null @@ -1,9 +0,0 @@ -pragma experimental "v0.5.0"; -contract C { - event e(); - function f() public { - e(); - } -} -// ---- -// TypeError: (92-95): Event invocations have to be prefixed by "emit". diff --git a/test/libsolidity/syntaxTests/tupleAssignments/error_fill.sol b/test/libsolidity/syntaxTests/tupleAssignments/error_fill.sol index ae722391..32b381bb 100644 --- a/test/libsolidity/syntaxTests/tupleAssignments/error_fill.sol +++ b/test/libsolidity/syntaxTests/tupleAssignments/error_fill.sol @@ -1,4 +1,3 @@ -pragma experimental "v0.5.0"; contract C { function f() public pure returns (uint, uint, bytes32) { uint a; @@ -8,5 +7,5 @@ contract C { } } // ---- -// TypeError: (133-136): Type tuple(uint256,uint256,bytes32) is not implicitly convertible to expected type tuple(uint256,). -// TypeError: (147-150): Type tuple(uint256,uint256,bytes32) is not implicitly convertible to expected type tuple(,bytes32). +// TypeError: (103-106): Type tuple(uint256,uint256,bytes32) is not implicitly convertible to expected type tuple(uint256,). +// TypeError: (117-120): Type tuple(uint256,uint256,bytes32) is not implicitly convertible to expected type tuple(,bytes32). diff --git a/test/libsolidity/syntaxTests/tupleAssignments/large_component_count.sol b/test/libsolidity/syntaxTests/tupleAssignments/large_component_count.sol index bbf21d7e..f14641cb 100644 --- a/test/libsolidity/syntaxTests/tupleAssignments/large_component_count.sol +++ b/test/libsolidity/syntaxTests/tupleAssignments/large_component_count.sol @@ -1,4 +1,3 @@ -pragma experimental "v0.5.0"; contract C { function g() public pure returns ( uint, diff --git a/test/libsolidity/syntaxTests/types/mapping/assignment_local.sol b/test/libsolidity/syntaxTests/types/mapping/assignment_local.sol new file mode 100644 index 00000000..a329c91e --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/assignment_local.sol @@ -0,0 +1,11 @@ +contract test { + mapping(uint=>uint) map; + function fun() public view { + mapping(uint=>uint) storage a = map; + mapping(uint=>uint) storage b = map; + b = a; + (b) = a; + (b, b) = (a, a); + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/types/mapping/assignment_state_variable.sol b/test/libsolidity/syntaxTests/types/mapping/assignment_state_variable.sol new file mode 100644 index 00000000..1323afe6 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/assignment_state_variable.sol @@ -0,0 +1,14 @@ +contract test { + mapping(uint=>uint) map; + function fun() public { + mapping(uint=>uint) storage a = map; + map = a; + (map) = a; + (map, map) = (a, a); + } +} +// ---- +// TypeError: (126-129): Mappings cannot be assigned to. +// TypeError: (144-147): Mappings cannot be assigned to. +// TypeError: (163-166): Mappings cannot be assigned to. +// TypeError: (168-171): Mappings cannot be assigned to. diff --git a/test/libsolidity/syntaxTests/types/mapping/assignment_struct.sol b/test/libsolidity/syntaxTests/types/mapping/assignment_struct.sol new file mode 100644 index 00000000..b89241ed --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/assignment_struct.sol @@ -0,0 +1,17 @@ +contract test { + struct str { + mapping(uint=>uint) map; + } + str data; + function fun() public { + mapping(uint=>uint) storage a = data.map; + data.map = a; + (data.map) = a; + (data.map, data.map) = (a, a); + } +} +// ---- +// TypeError: (172-180): Mappings cannot be assigned to. +// TypeError: (195-203): Mappings cannot be assigned to. +// TypeError: (219-227): Mappings cannot be assigned to. +// TypeError: (229-237): Mappings cannot be assigned to. diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_return_external.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_return_external.sol new file mode 100644 index 00000000..85121241 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/mapping_return_external.sol @@ -0,0 +1,7 @@ +contract C { + function f() external pure returns (mapping(uint=>uint) storage m) { + } +} +// ---- +// TypeError: (53-82): Type is required to live outside storage. +// TypeError: (53-82): Internal or recursive type is not allowed for public or external functions. diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_return_internal.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_return_internal.sol new file mode 100644 index 00000000..a46003f8 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/mapping_return_internal.sol @@ -0,0 +1,21 @@ +// This should be allowed in a future release. +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); + } +} +// ---- +// 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/mapping/mapping_return_public.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_return_public.sol new file mode 100644 index 00000000..383fa797 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/mapping_return_public.sol @@ -0,0 +1,7 @@ +contract C { + function f() public pure returns (mapping(uint=>uint) storage m) { + } +} +// ---- +// TypeError: (51-80): Type is required to live outside storage. +// TypeError: (51-80): Internal or recursive type is not allowed for public or external functions. diff --git a/test/libsolidity/syntaxTests/types/var_type_suggest.sol b/test/libsolidity/syntaxTests/types/var_type_suggest.sol index 176fab96..cc35fdd6 100644 --- a/test/libsolidity/syntaxTests/types/var_type_suggest.sol +++ b/test/libsolidity/syntaxTests/types/var_type_suggest.sol @@ -12,6 +12,10 @@ contract C { var myblockhash = block.blockhash; var (a, b) = (2, "troi"); var (x,, z) = h(); + var (c, d) = (""); + var (k, l) = (2); + var (m, n) = 1; + var (o, p) = ""; } } // ---- @@ -21,3 +25,11 @@ contract C { // SyntaxError: (293-326): Use of the "var" keyword is disallowed. Type cannot be expressed in syntax. // SyntaxError: (336-360): Use of the "var" keyword is disallowed. Use explicit declaration `(uint8 a, string memory b) = ...´ instead. // SyntaxError: (370-387): Use of the "var" keyword is disallowed. Use explicit declaration `(uint256 x, , uint256 z) = ...´ instead. +// TypeError: (397-414): Different number of components on the left hand side (2) than on the right hand side (1). +// SyntaxError: (397-414): Use of the "var" keyword is disallowed. Type cannot be expressed in syntax. +// TypeError: (424-440): Different number of components on the left hand side (2) than on the right hand side (1). +// SyntaxError: (424-440): Use of the "var" keyword is disallowed. Type cannot be expressed in syntax. +// TypeError: (450-464): Different number of components on the left hand side (2) than on the right hand side (1). +// SyntaxError: (450-464): Use of the "var" keyword is disallowed. Type cannot be expressed in syntax. +// TypeError: (474-489): Different number of components on the left hand side (2) than on the right hand side (1). +// SyntaxError: (474-489): Use of the "var" keyword is disallowed. Type cannot be expressed in syntax. diff --git a/test/libsolidity/syntaxTests/visibility/interface/function_external050.sol b/test/libsolidity/syntaxTests/visibility/interface/function_external.sol index 3f0a9aca..ed409e58 100644 --- a/test/libsolidity/syntaxTests/visibility/interface/function_external050.sol +++ b/test/libsolidity/syntaxTests/visibility/interface/function_external.sol @@ -1,4 +1,3 @@ -pragma experimental "v0.5.0"; interface I { function f() external; } diff --git a/test/libsolidity/syntaxTests/visibility/interface/function_public050.sol b/test/libsolidity/syntaxTests/visibility/interface/function_public050.sol deleted file mode 100644 index e0c04095..00000000 --- a/test/libsolidity/syntaxTests/visibility/interface/function_public050.sol +++ /dev/null @@ -1,6 +0,0 @@ -pragma experimental "v0.5.0"; -interface I { - function f() public; -} -// ---- -// TypeError: (45-65): Functions in interfaces must be declared external. |