diff options
Diffstat (limited to 'test/libsolidity/syntaxTests')
174 files changed, 2528 insertions, 0 deletions
diff --git a/test/libsolidity/syntaxTests/arrayLength/array_length_cannot_be_constant_function_parameter.sol b/test/libsolidity/syntaxTests/arrayLength/array_length_cannot_be_constant_function_parameter.sol new file mode 100644 index 00000000..11d40f26 --- /dev/null +++ b/test/libsolidity/syntaxTests/arrayLength/array_length_cannot_be_constant_function_parameter.sol @@ -0,0 +1,7 @@ +contract C { + function f(uint constant LEN) { + uint[LEN] a; + } +} +// ---- +// TypeError: (62-65): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/arrayLength/can_be_constant_in_function.sol b/test/libsolidity/syntaxTests/arrayLength/can_be_constant_in_function.sol new file mode 100644 index 00000000..92536dd5 --- /dev/null +++ b/test/libsolidity/syntaxTests/arrayLength/can_be_constant_in_function.sol @@ -0,0 +1,8 @@ +contract C { + uint constant LEN = 10; + function f() public pure { + uint[LEN] memory a; + a; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/arrayLength/can_be_constant_in_struct.sol b/test/libsolidity/syntaxTests/arrayLength/can_be_constant_in_struct.sol new file mode 100644 index 00000000..89e174f2 --- /dev/null +++ b/test/libsolidity/syntaxTests/arrayLength/can_be_constant_in_struct.sol @@ -0,0 +1,7 @@ +contract C { + uint constant LEN = 10; + struct Test { + uint[LEN] ids; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/arrayLength/can_be_recursive_constant.sol b/test/libsolidity/syntaxTests/arrayLength/can_be_recursive_constant.sol new file mode 100644 index 00000000..6810a9d6 --- /dev/null +++ b/test/libsolidity/syntaxTests/arrayLength/can_be_recursive_constant.sol @@ -0,0 +1,6 @@ +contract C { + uint constant L = 5; + uint constant LEN = L + 4 * L; + uint[LEN] ids; +} +// ---- diff --git a/test/libsolidity/syntaxTests/arrayLength/cannot_be_function.sol b/test/libsolidity/syntaxTests/arrayLength/cannot_be_function.sol new file mode 100644 index 00000000..ac3abc4c --- /dev/null +++ b/test/libsolidity/syntaxTests/arrayLength/cannot_be_function.sol @@ -0,0 +1,6 @@ +contract C { + function f() {} + uint[f] ids; +} +// ---- +// TypeError: (42-43): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/arrayLength/cannot_be_function_call.sol b/test/libsolidity/syntaxTests/arrayLength/cannot_be_function_call.sol new file mode 100644 index 00000000..a6863955 --- /dev/null +++ b/test/libsolidity/syntaxTests/arrayLength/cannot_be_function_call.sol @@ -0,0 +1,7 @@ +contract C { + function f(uint x) {} + uint constant LEN = f(); + uint[LEN] ids; +} +// ---- +// TypeError: (77-80): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/arrayLength/complex_cyclic_constant.sol b/test/libsolidity/syntaxTests/arrayLength/complex_cyclic_constant.sol new file mode 100644 index 00000000..254f9f02 --- /dev/null +++ b/test/libsolidity/syntaxTests/arrayLength/complex_cyclic_constant.sol @@ -0,0 +1,10 @@ +contract C { + uint constant L2 = LEN - 10; + uint constant L1 = L2 / 10; + uint constant LEN = 10 + L1 * 5; + function f() { + uint[LEN] a; + } +} +// ---- +// TypeError: (36-39): Cyclic constant definition (or maximum recursion depth exhausted). diff --git a/test/libsolidity/syntaxTests/arrayLength/const_cannot_be_fractional.sol b/test/libsolidity/syntaxTests/arrayLength/const_cannot_be_fractional.sol new file mode 100644 index 00000000..397bbbcd --- /dev/null +++ b/test/libsolidity/syntaxTests/arrayLength/const_cannot_be_fractional.sol @@ -0,0 +1,6 @@ +contract C { + fixed constant L = 10.5; + uint[L] ids; +} +// ---- +// TypeError: (51-52): Array with fractional length specified. diff --git a/test/libsolidity/syntaxTests/arrayLength/constant_var.sol b/test/libsolidity/syntaxTests/arrayLength/constant_var.sol new file mode 100644 index 00000000..41750250 --- /dev/null +++ b/test/libsolidity/syntaxTests/arrayLength/constant_var.sol @@ -0,0 +1,5 @@ +contract C { + uint constant LEN = 10; + uint[LEN] ids; +} +// ----
\ No newline at end of file diff --git a/test/libsolidity/syntaxTests/arrayLength/cyclic_constant.sol b/test/libsolidity/syntaxTests/arrayLength/cyclic_constant.sol new file mode 100644 index 00000000..91ba9045 --- /dev/null +++ b/test/libsolidity/syntaxTests/arrayLength/cyclic_constant.sol @@ -0,0 +1,8 @@ +contract C { + uint constant LEN = LEN; + function f() { + uint[LEN] a; + } +} +// ---- +// TypeError: (37-40): Cyclic constant definition (or maximum recursion depth exhausted). diff --git a/test/libsolidity/syntaxTests/arrayLength/inline_array.sol b/test/libsolidity/syntaxTests/arrayLength/inline_array.sol new file mode 100644 index 00000000..a30745d3 --- /dev/null +++ b/test/libsolidity/syntaxTests/arrayLength/inline_array.sol @@ -0,0 +1,5 @@ +contract C { + uint[[2]] a15; +} +// ---- +// TypeError: (22-25): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/arrayLength/invalid_expression_1.sol b/test/libsolidity/syntaxTests/arrayLength/invalid_expression_1.sol new file mode 100644 index 00000000..c92861eb --- /dev/null +++ b/test/libsolidity/syntaxTests/arrayLength/invalid_expression_1.sol @@ -0,0 +1,5 @@ +contract C { + uint[-true] ids; +} +// ---- +// TypeError: (22-27): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/arrayLength/invalid_expression_2.sol b/test/libsolidity/syntaxTests/arrayLength/invalid_expression_2.sol new file mode 100644 index 00000000..92e3c3cf --- /dev/null +++ b/test/libsolidity/syntaxTests/arrayLength/invalid_expression_2.sol @@ -0,0 +1,5 @@ +contract C { + uint[true/1] ids; +} +// ---- +// TypeError: (22-28): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/arrayLength/invalid_expression_3.sol b/test/libsolidity/syntaxTests/arrayLength/invalid_expression_3.sol new file mode 100644 index 00000000..26add45c --- /dev/null +++ b/test/libsolidity/syntaxTests/arrayLength/invalid_expression_3.sol @@ -0,0 +1,5 @@ +contract C { + uint[1/true] ids; +} +// ---- +// TypeError: (22-28): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/arrayLength/invalid_expression_4.sol b/test/libsolidity/syntaxTests/arrayLength/invalid_expression_4.sol new file mode 100644 index 00000000..a0d58f4a --- /dev/null +++ b/test/libsolidity/syntaxTests/arrayLength/invalid_expression_4.sol @@ -0,0 +1,5 @@ +contract C { + uint[1.111111E1111111111111] ids; +} +// ---- +// TypeError: (22-44): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/arrayLength/invalid_expression_5.sol b/test/libsolidity/syntaxTests/arrayLength/invalid_expression_5.sol new file mode 100644 index 00000000..38a80867 --- /dev/null +++ b/test/libsolidity/syntaxTests/arrayLength/invalid_expression_5.sol @@ -0,0 +1,5 @@ +contract C { + uint[3/0] ids; +} +// ---- +// TypeError: (22-25): Operator / not compatible with types int_const 3 and int_const 0 diff --git a/test/libsolidity/syntaxTests/arrayLength/non_integer_constant_var.sol b/test/libsolidity/syntaxTests/arrayLength/non_integer_constant_var.sol new file mode 100644 index 00000000..7a853a34 --- /dev/null +++ b/test/libsolidity/syntaxTests/arrayLength/non_integer_constant_var.sol @@ -0,0 +1,6 @@ +contract C { + bool constant LEN = true; + uint[LEN] ids; +} +// ---- +// TypeError: (52-55): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/arrayLength/not_convertible_to_integer.sol b/test/libsolidity/syntaxTests/arrayLength/not_convertible_to_integer.sol new file mode 100644 index 00000000..b44ccfe9 --- /dev/null +++ b/test/libsolidity/syntaxTests/arrayLength/not_convertible_to_integer.sol @@ -0,0 +1,5 @@ +contract C { + uint[true] ids; +} +// ---- +// TypeError: (22-26): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/arrayLength/parentheses.sol b/test/libsolidity/syntaxTests/arrayLength/parentheses.sol new file mode 100644 index 00000000..40f55ad6 --- /dev/null +++ b/test/libsolidity/syntaxTests/arrayLength/parentheses.sol @@ -0,0 +1,25 @@ +contract C { + uint constant L1 = (2); + uint constant L2 = ((2)); + uint constant L3 = ((((2)))); + uint constant L4 = (2 + 1); + uint constant L5 = ((2 + 1)); + uint constant L6 = (((2) + ((1)))); + uint constant L7 = (2 + 1) / 1; + uint constant L8 = (2 + ((1))) / (1); + uint[L1] a1; + uint[L2] a2; + uint[L3] a3; + uint[L4] a4; + uint[L5] a5; + uint[L6] a6; + uint[L7] a7; + uint[L8] a8; + uint[(2)] a9; + uint[(2 + 1)] a10; + uint[(2 + 1) + 1] a11; + uint[((2) + 1) + 1] a12; + uint[(2 + 1) + ((1))] a13; + uint[(((2) + 1)) + (((1)))] a14; + uint[((((2) + 1)) + (((1))))%1] a15; +} diff --git a/test/libsolidity/syntaxTests/arrayLength/pure_functions.sol b/test/libsolidity/syntaxTests/arrayLength/pure_functions.sol new file mode 100644 index 00000000..b620db76 --- /dev/null +++ b/test/libsolidity/syntaxTests/arrayLength/pure_functions.sol @@ -0,0 +1,6 @@ +contract C { + uint constant LEN = keccak256(ripemd160(33)); + uint[LEN] ids; +} +// ---- +// TypeError: (72-75): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/arrayLength/too_large.sol b/test/libsolidity/syntaxTests/arrayLength/too_large.sol new file mode 100644 index 00000000..c90a7494 --- /dev/null +++ b/test/libsolidity/syntaxTests/arrayLength/too_large.sol @@ -0,0 +1,5 @@ +contract C { + uint[8**90] ids; +} +// ---- +// TypeError: (22-27): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/arrayLength/tuples.sol b/test/libsolidity/syntaxTests/arrayLength/tuples.sol new file mode 100644 index 00000000..bc10b3b5 --- /dev/null +++ b/test/libsolidity/syntaxTests/arrayLength/tuples.sol @@ -0,0 +1,5 @@ +contract C { + uint[(1,2)] a15; +} +// ---- +// TypeError: (22-27): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/constants/addmod_mulmod_rational.sol b/test/libsolidity/syntaxTests/constants/addmod_mulmod_rational.sol new file mode 100644 index 00000000..26712735 --- /dev/null +++ b/test/libsolidity/syntaxTests/constants/addmod_mulmod_rational.sol @@ -0,0 +1,7 @@ +contract C { + uint constant a = addmod(3, 4, 0.1); + uint constant b = mulmod(3, 4, 0.1); +} +// ---- +// TypeError: (48-51): Invalid type for argument in function call. Invalid implicit conversion from rational_const 1 / 10 to uint256 requested. +// TypeError: (89-92): Invalid type for argument in function call. Invalid implicit conversion from rational_const 1 / 10 to uint256 requested. diff --git a/test/libsolidity/syntaxTests/constants/addmod_zero.sol b/test/libsolidity/syntaxTests/constants/addmod_zero.sol new file mode 100644 index 00000000..18f7d64a --- /dev/null +++ b/test/libsolidity/syntaxTests/constants/addmod_zero.sol @@ -0,0 +1,11 @@ +contract c { + uint constant a1 = 0; + uint constant a2 = 1; + uint constant b1 = addmod(3, 4, 0); + uint constant b2 = addmod(3, 4, a1); + uint constant b3 = addmod(3, 4, a2 - 1); +} +// ---- +// TypeError: (88-103): Arithmetic modulo zero. +// TypeError: (128-144): Arithmetic modulo zero. +// TypeError: (169-189): Arithmetic modulo zero. diff --git a/test/libsolidity/syntaxTests/constants/cyclic_dependency_1.sol b/test/libsolidity/syntaxTests/constants/cyclic_dependency_1.sol new file mode 100644 index 00000000..cb553fbe --- /dev/null +++ b/test/libsolidity/syntaxTests/constants/cyclic_dependency_1.sol @@ -0,0 +1,5 @@ +contract C { + uint constant a = a; +} +// ---- +// TypeError: (17-36): The value of the constant a has a cyclic dependency via a. diff --git a/test/libsolidity/syntaxTests/constants/cyclic_dependency_2.sol b/test/libsolidity/syntaxTests/constants/cyclic_dependency_2.sol new file mode 100644 index 00000000..00f9bb0f --- /dev/null +++ b/test/libsolidity/syntaxTests/constants/cyclic_dependency_2.sol @@ -0,0 +1,10 @@ +contract C { + uint constant a = b * c; + uint constant b = 7; + uint constant c = b + uint(keccak256(d)); + uint constant d = 2 + a; +} +// ---- +// TypeError: (17-40): The value of the constant a has a cyclic dependency via c. +// TypeError: (71-111): The value of the constant c has a cyclic dependency via d. +// TypeError: (117-140): The value of the constant d has a cyclic dependency via a. diff --git a/test/libsolidity/syntaxTests/constants/cyclic_dependency_3.sol b/test/libsolidity/syntaxTests/constants/cyclic_dependency_3.sol new file mode 100644 index 00000000..969ed50d --- /dev/null +++ b/test/libsolidity/syntaxTests/constants/cyclic_dependency_3.sol @@ -0,0 +1,11 @@ +contract C { + uint constant x = a; + uint constant a = b * c; + uint constant b = c; + uint constant c = b; +} +// ---- +// TypeError: (17-36): The value of the constant x has a cyclic dependency via a. +// TypeError: (42-65): The value of the constant a has a cyclic dependency via b. +// TypeError: (71-90): The value of the constant b has a cyclic dependency via c. +// TypeError: (96-115): The value of the constant c has a cyclic dependency via b. diff --git a/test/libsolidity/syntaxTests/constants/cyclic_dependency_4.sol b/test/libsolidity/syntaxTests/constants/cyclic_dependency_4.sol new file mode 100644 index 00000000..f01cb98e --- /dev/null +++ b/test/libsolidity/syntaxTests/constants/cyclic_dependency_4.sol @@ -0,0 +1,6 @@ +contract C { + uint constant a = b * c; + uint constant b = 7; + uint constant c = 4 + uint(keccak256(d)); + uint constant d = 2 + b; +}
\ No newline at end of file diff --git a/test/libsolidity/syntaxTests/constants/division_by_zero.sol b/test/libsolidity/syntaxTests/constants/division_by_zero.sol new file mode 100644 index 00000000..bf6000ec --- /dev/null +++ b/test/libsolidity/syntaxTests/constants/division_by_zero.sol @@ -0,0 +1,9 @@ +contract c { + uint constant a1 = 0; + uint constant a2 = 1; + uint constant b1 = 7 / a1; + uint constant b2 = 7 / (a2 - 1); +} +// ---- +// TypeError: (88-94): Division by zero. +// TypeError: (119-131): Division by zero. diff --git a/test/libsolidity/syntaxTests/constants/mod_div_rational.sol b/test/libsolidity/syntaxTests/constants/mod_div_rational.sol new file mode 100644 index 00000000..f8b6ce31 --- /dev/null +++ b/test/libsolidity/syntaxTests/constants/mod_div_rational.sol @@ -0,0 +1,6 @@ +contract C { + fixed a1 = 0.1 % -0.4271087646484375; + fixed a2 = 0.1 % 0.4271087646484375; + fixed a3 = 0 / 0.123; + fixed a4 = 0 / -0.123; +} diff --git a/test/libsolidity/syntaxTests/constants/mod_zero.sol b/test/libsolidity/syntaxTests/constants/mod_zero.sol new file mode 100644 index 00000000..f5e4a23a --- /dev/null +++ b/test/libsolidity/syntaxTests/constants/mod_zero.sol @@ -0,0 +1,9 @@ +contract c { + uint constant a1 = 0; + uint constant a2 = 1; + uint constant b1 = 3 % a1; + uint constant b2 = 3 % (a2 - 1); +} +// ---- +// TypeError: (88-94): Modulo zero. +// TypeError: (119-131): Modulo zero. diff --git a/test/libsolidity/syntaxTests/constants/mulmod_zero.sol b/test/libsolidity/syntaxTests/constants/mulmod_zero.sol new file mode 100644 index 00000000..856d01eb --- /dev/null +++ b/test/libsolidity/syntaxTests/constants/mulmod_zero.sol @@ -0,0 +1,11 @@ +contract c { + uint constant a1 = 0; + uint constant a2 = 1; + uint constant b1 = mulmod(3, 4, 0); + uint constant b2 = mulmod(3, 4, a1); + uint constant b3 = mulmod(3, 4, a2 - 1); +} +// ---- +// TypeError: (88-103): Arithmetic modulo zero. +// TypeError: (128-144): Arithmetic modulo zero. +// TypeError: (169-189): Arithmetic modulo zero. diff --git a/test/libsolidity/syntaxTests/constants/pure_non_rational.sol b/test/libsolidity/syntaxTests/constants/pure_non_rational.sol new file mode 100644 index 00000000..4b96f1c7 --- /dev/null +++ b/test/libsolidity/syntaxTests/constants/pure_non_rational.sol @@ -0,0 +1,11 @@ +// Tests that the ConstantEvaluator does not crash for pure non-rational functions. +// Currently it does not evaluate such functions, but this may change in the future +// causing a division by zero error for a. +contract C { + uint constant a = 1 / (uint(keccak256([0])[0]) - uint(keccak256([0])[0])); + uint constant b = 1 / uint(keccak256([0])); + uint constant c = uint(keccak256([0])); + uint[c] mem; +} +// ---- +// TypeError: (392-393): Invalid array length, expected integer literal or constant expression. diff --git a/test/libsolidity/syntaxTests/constructor_this.sol b/test/libsolidity/syntaxTests/constructor_this.sol new file mode 100644 index 00000000..9d22a161 --- /dev/null +++ b/test/libsolidity/syntaxTests/constructor_this.sol @@ -0,0 +1,12 @@ +contract C { + function f() public pure {} + constructor() public { + C c = this; + c.f(); // this does not warn now, but should warn in the future + this.f(); + (this).f(); + } +} +// ---- +// Warning: (172-176): "this" used in constructor. Note that external functions of a contract cannot be called while it is being constructed. +// Warning: (191-195): "this" used in constructor. Note that external functions of a contract cannot be called while it is being constructed. diff --git a/test/libsolidity/syntaxTests/docstring_empty_description.sol b/test/libsolidity/syntaxTests/docstring_empty_description.sol new file mode 100644 index 00000000..0caa1b23 --- /dev/null +++ b/test/libsolidity/syntaxTests/docstring_empty_description.sol @@ -0,0 +1,6 @@ +contract C { + /// @param id + function vote(uint id) public; +} +// ---- +// DocstringParsingError: No description given for param id diff --git a/test/libsolidity/syntaxTests/double_stateVariable_declaration.sol b/test/libsolidity/syntaxTests/double_stateVariable_declaration.sol new file mode 100644 index 00000000..fda4a17a --- /dev/null +++ b/test/libsolidity/syntaxTests/double_stateVariable_declaration.sol @@ -0,0 +1,6 @@ +contract test { + uint256 variable; + uint128 variable; +} +// ---- +// DeclarationError: (36-52): Identifier already declared. diff --git a/test/libsolidity/syntaxTests/double_variable_declaration.sol b/test/libsolidity/syntaxTests/double_variable_declaration.sol new file mode 100644 index 00000000..9ab87959 --- /dev/null +++ b/test/libsolidity/syntaxTests/double_variable_declaration.sol @@ -0,0 +1,8 @@ +contract test { + function f() pure public { + uint256 x; + if (true) { uint256 x; } + } +} +// ---- +// DeclarationError: (71-80): Identifier already declared. diff --git a/test/libsolidity/syntaxTests/double_variable_declaration_050.sol b/test/libsolidity/syntaxTests/double_variable_declaration_050.sol new file mode 100644 index 00000000..2f47e6dc --- /dev/null +++ b/test/libsolidity/syntaxTests/double_variable_declaration_050.sol @@ -0,0 +1,11 @@ +pragma experimental "v0.5.0"; +contract test { + function f() pure public { + uint256 x; + if (true) { uint256 x; } + } +} +// ---- +// Warning: (101-110): This declaration shadows an existing declaration. +// Warning: (76-85): Unused local variable. +// Warning: (101-110): Unused local variable. diff --git a/test/libsolidity/syntaxTests/empty_struct.sol b/test/libsolidity/syntaxTests/empty_struct.sol new file mode 100644 index 00000000..12655309 --- /dev/null +++ b/test/libsolidity/syntaxTests/empty_struct.sol @@ -0,0 +1,5 @@ +contract test { + struct A {} +} +// ---- +// Warning: (17-28): Defining empty structs is deprecated. diff --git a/test/libsolidity/syntaxTests/empty_struct_050.sol b/test/libsolidity/syntaxTests/empty_struct_050.sol new file mode 100644 index 00000000..886f1f83 --- /dev/null +++ b/test/libsolidity/syntaxTests/empty_struct_050.sol @@ -0,0 +1,6 @@ +pragma experimental "v0.5.0"; +contract test { + struct A {} +} +// ---- +// SyntaxError: (47-58): Defining empty structs is disallowed. diff --git a/test/libsolidity/syntaxTests/functionCalls/arbitrary_parameters_but_restricted_first_type.sol b/test/libsolidity/syntaxTests/functionCalls/arbitrary_parameters_but_restricted_first_type.sol new file mode 100644 index 00000000..94da5881 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionCalls/arbitrary_parameters_but_restricted_first_type.sol @@ -0,0 +1,13 @@ +contract C { + function f() pure public { + abi.encodeWithSelector(); + abi.encodeWithSignature(); + abi.encodeWithSelector(uint(2), 2); + abi.encodeWithSignature(uint(2), 2); + } +} +// ---- +// TypeError: (52-76): Need at least 1 arguments for function call, but provided only 0. +// TypeError: (86-111): Need at least 1 arguments for function call, but provided only 0. +// TypeError: (144-151): Invalid type for argument in function call. Invalid implicit conversion from uint256 to bytes4 requested. +// TypeError: (189-196): Invalid type for argument in function call. Invalid implicit conversion from uint256 to string memory requested. diff --git a/test/libsolidity/syntaxTests/functionTypes/call_value_on_non_payable_function_type.sol b/test/libsolidity/syntaxTests/functionTypes/call_value_on_non_payable_function_type.sol new file mode 100644 index 00000000..87c3b05b --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/call_value_on_non_payable_function_type.sol @@ -0,0 +1,8 @@ +contract C { + function (uint) external returns (uint) x; + function f() public { + x.value(2)(); + } +} +// ---- +// TypeError: (94-101): Member "value" not found or not visible after argument-dependent lookup in function (uint256) external returns (uint256) - did you forget the "payable" modifier? diff --git a/test/libsolidity/syntaxTests/functionTypes/call_value_on_payable_function_type.sol b/test/libsolidity/syntaxTests/functionTypes/call_value_on_payable_function_type.sol new file mode 100644 index 00000000..ca2a0196 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/call_value_on_payable_function_type.sol @@ -0,0 +1,6 @@ +contract C { + function (uint) external payable returns (uint) x; + function f() public { + x.value(2)(1); + } +} diff --git a/test/libsolidity/syntaxTests/functionTypes/delete_external_function_type_invalid.sol b/test/libsolidity/syntaxTests/functionTypes/delete_external_function_type_invalid.sol new file mode 100644 index 00000000..2711dae8 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/delete_external_function_type_invalid.sol @@ -0,0 +1,7 @@ +contract C { + function f() public { + delete this.f; + } +} +// ---- +// TypeError: (54-60): Expression has to be an lvalue. diff --git a/test/libsolidity/syntaxTests/functionTypes/delete_function_type.sol b/test/libsolidity/syntaxTests/functionTypes/delete_function_type.sol new file mode 100644 index 00000000..a6fe6c22 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/delete_function_type.sol @@ -0,0 +1,17 @@ +contract C { + function(uint) external returns (uint) x; + function(uint) internal returns (uint) y; + function f() public { + delete x; + var a = y; + delete a; + delete y; + var c = f; + delete c; + function(uint) internal returns (uint) g; + delete g; + } +} +// ---- +// Warning: (157-162): Use of the "var" keyword is deprecated. +// Warning: (212-217): Use of the "var" keyword is deprecated. diff --git a/test/libsolidity/syntaxTests/functionTypes/delete_function_type_invalid.sol b/test/libsolidity/syntaxTests/functionTypes/delete_function_type_invalid.sol new file mode 100644 index 00000000..60da19e4 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/delete_function_type_invalid.sol @@ -0,0 +1,7 @@ +contract C { + function f() public { + delete f; + } +} +// ---- +// TypeError: (54-55): Expression has to be an lvalue. diff --git a/test/libsolidity/syntaxTests/functionTypes/external_function_to_function_type_calldata_parameter.sol b/test/libsolidity/syntaxTests/functionTypes/external_function_to_function_type_calldata_parameter.sol new file mode 100644 index 00000000..eb4f0693 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/external_function_to_function_type_calldata_parameter.sol @@ -0,0 +1,10 @@ +// This is a test that checks that the type of the `bytes` parameter is +// correctly changed from its own type `bytes calldata` to `bytes memory` +// when converting to a function type. +contract C { + function f(function(bytes memory) pure external /*g*/) pure public { } + function callback(bytes) pure external {} + function g() view public { + f(this.callback); + } +} diff --git a/test/libsolidity/syntaxTests/functionTypes/external_function_type_public_variable.sol b/test/libsolidity/syntaxTests/functionTypes/external_function_type_public_variable.sol new file mode 100644 index 00000000..0a6d1e53 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/external_function_type_public_variable.sol @@ -0,0 +1,11 @@ +contract C { + function (uint) external public x; + + function g(uint) public { + x = this.g; + } + function f() public view returns (function(uint) external) { + return this.x(); + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/functionTypes/external_function_type_returning_internal.sol b/test/libsolidity/syntaxTests/functionTypes/external_function_type_returning_internal.sol new file mode 100644 index 00000000..8b14d3dc --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/external_function_type_returning_internal.sol @@ -0,0 +1,5 @@ +contract C { + function() external returns (function () internal) x; +} +// ---- +// TypeError: (46-67): Internal type cannot be used for external function type. diff --git a/test/libsolidity/syntaxTests/functionTypes/external_function_type_taking_internal.sol b/test/libsolidity/syntaxTests/functionTypes/external_function_type_taking_internal.sol new file mode 100644 index 00000000..3e264c8c --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/external_function_type_taking_internal.sol @@ -0,0 +1,5 @@ +contract C { + function(function () internal) external x; +} +// ---- +// TypeError: (26-47): Internal type cannot be used for external function type. diff --git a/test/libsolidity/syntaxTests/functionTypes/external_function_type_to_address.sol b/test/libsolidity/syntaxTests/functionTypes/external_function_type_to_address.sol new file mode 100644 index 00000000..b86425db --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/external_function_type_to_address.sol @@ -0,0 +1,5 @@ +contract C { + function f() public view returns (address) { + return address(this.f); + } +} diff --git a/test/libsolidity/syntaxTests/functionTypes/external_function_type_to_uint.sol b/test/libsolidity/syntaxTests/functionTypes/external_function_type_to_uint.sol new file mode 100644 index 00000000..f4287223 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/external_function_type_to_uint.sol @@ -0,0 +1,7 @@ +contract C { + function f() public returns (uint) { + return uint(this.f); + } +} +// ---- +// TypeError: (69-81): Explicit type conversion not allowed from "function () external returns (uint256)" to "uint256". diff --git a/test/libsolidity/syntaxTests/functionTypes/function_type.sol b/test/libsolidity/syntaxTests/functionTypes/function_type.sol new file mode 100644 index 00000000..23d50136 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/function_type.sol @@ -0,0 +1,6 @@ +contract C { + function f() pure public { + function(uint) returns (uint) x; + x; + } +} diff --git a/test/libsolidity/syntaxTests/functionTypes/function_type_arrays.sol b/test/libsolidity/syntaxTests/functionTypes/function_type_arrays.sol new file mode 100644 index 00000000..ec23d637 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/function_type_arrays.sol @@ -0,0 +1,11 @@ +contract C { + function(uint) external returns (uint)[] public x; + function(uint) internal returns (uint)[10] y; + function f() view public { + function(uint) returns (uint)[10] memory a; + function(uint) returns (uint)[10] storage b = y; + function(uint) external returns (uint)[] memory c; + c = new function(uint) external returns (uint)[](200); + a; b; + } +} diff --git a/test/libsolidity/syntaxTests/functionTypes/function_type_constructor.sol b/test/libsolidity/syntaxTests/functionTypes/function_type_constructor.sol new file mode 100644 index 00000000..95ebc179 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/function_type_constructor.sol @@ -0,0 +1,7 @@ +contract C { + // Fool parser into parsing a constructor as a function type. + constructor() x; +} +// ---- +// Warning: (83-99): Modifiers of functions without implementation are ignored. +// DeclarationError: (97-98): Undeclared identifier. diff --git a/test/libsolidity/syntaxTests/functionTypes/function_type_constructor_local.sol b/test/libsolidity/syntaxTests/functionTypes/function_type_constructor_local.sol new file mode 100644 index 00000000..b7763d28 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/function_type_constructor_local.sol @@ -0,0 +1,8 @@ +contract C { + // Fool parser into parsing a constructor as a function type. + function f() { + constructor() x; + } +} +// ---- +// ParserError: (118-118): Expected token Semicolon got 'Identifier' diff --git a/test/libsolidity/syntaxTests/functionTypes/function_type_internal_public_variable.sol b/test/libsolidity/syntaxTests/functionTypes/function_type_internal_public_variable.sol new file mode 100644 index 00000000..4eb53227 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/function_type_internal_public_variable.sol @@ -0,0 +1,5 @@ +contract C { + function(bytes memory) internal public a; +} +// ---- +// TypeError: (17-57): Internal or recursive type is not allowed for public state variables. diff --git a/test/libsolidity/syntaxTests/functionTypes/function_type_parameter.sol b/test/libsolidity/syntaxTests/functionTypes/function_type_parameter.sol new file mode 100644 index 00000000..da66ec8a --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/function_type_parameter.sol @@ -0,0 +1,7 @@ +contract C { + uint x; + function f(function(uint) external returns (uint) g) public returns (function(uint) external returns (uint)) { + x = 2; + return g; + } +} diff --git a/test/libsolidity/syntaxTests/functionTypes/function_type_returned.sol b/test/libsolidity/syntaxTests/functionTypes/function_type_returned.sol new file mode 100644 index 00000000..9cd313c8 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/function_type_returned.sol @@ -0,0 +1,5 @@ +contract C { + function f() public pure returns (function(uint) pure external returns (uint) g) { + return g; + } +} diff --git a/test/libsolidity/syntaxTests/functionTypes/function_type_variable_external_internal.sol b/test/libsolidity/syntaxTests/functionTypes/function_type_variable_external_internal.sol new file mode 100644 index 00000000..f0240472 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/function_type_variable_external_internal.sol @@ -0,0 +1,6 @@ +contract test { + function fa(bytes memory) public { } + function(bytes memory) external internal a = fa; +} +// ---- +// TypeError: (106-108): Type function (bytes memory) is not implicitly convertible to expected type function (bytes memory) external. diff --git a/test/libsolidity/syntaxTests/functionTypes/function_types_internal_visibility_error.sol b/test/libsolidity/syntaxTests/functionTypes/function_types_internal_visibility_error.sol new file mode 100644 index 00000000..36206d63 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/function_types_internal_visibility_error.sol @@ -0,0 +1,7 @@ +contract C { + // This is an error, you should explicitly use + // `external public` to fix it - `internal public` does not exist. + function(bytes memory) public a; +} +// ---- +// TypeError: (139-170): Invalid visibility, can only be "external" or "internal". diff --git a/test/libsolidity/syntaxTests/functionTypes/function_types_variable_visibility.sol b/test/libsolidity/syntaxTests/functionTypes/function_types_variable_visibility.sol new file mode 100644 index 00000000..91c2420a --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/function_types_variable_visibility.sol @@ -0,0 +1,9 @@ +contract C { + function(bytes memory) a1; + function(bytes memory) internal b1; + function(bytes memory) internal internal b2; + function(bytes memory) external c1; + function(bytes memory) external internal c2; + function(bytes memory) external public c3; +} +// ---- diff --git a/test/libsolidity/syntaxTests/functionTypes/internal_function_as_external_parameter.sol b/test/libsolidity/syntaxTests/functionTypes/internal_function_as_external_parameter.sol new file mode 100644 index 00000000..fa92d559 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/internal_function_as_external_parameter.sol @@ -0,0 +1,8 @@ +// It should not be possible to give internal functions +// as parameters to external functions. +contract C { + function f(function(uint) internal returns (uint) x) public { + } +} +// ---- +// TypeError: (124-164): Internal or recursive type is not allowed for public or external functions. diff --git a/test/libsolidity/syntaxTests/functionTypes/internal_function_as_external_parameter_in_library_external.sol b/test/libsolidity/syntaxTests/functionTypes/internal_function_as_external_parameter_in_library_external.sol new file mode 100644 index 00000000..b37fb285 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/internal_function_as_external_parameter_in_library_external.sol @@ -0,0 +1,6 @@ +library L { + function f(function(uint) internal returns (uint) x) public { + } +} +// ---- +// TypeError: (27-67): Internal or recursive type is not allowed for public or external functions. diff --git a/test/libsolidity/syntaxTests/functionTypes/internal_function_as_external_parameter_in_library_internal.sol b/test/libsolidity/syntaxTests/functionTypes/internal_function_as_external_parameter_in_library_internal.sol new file mode 100644 index 00000000..7ffa447e --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/internal_function_as_external_parameter_in_library_internal.sol @@ -0,0 +1,4 @@ +library L { + function f(function(uint) internal returns (uint) /*x*/) pure internal { + } +} diff --git a/test/libsolidity/syntaxTests/functionTypes/internal_function_returned_from_public_function.sol b/test/libsolidity/syntaxTests/functionTypes/internal_function_returned_from_public_function.sol new file mode 100644 index 00000000..41fcd0a4 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/internal_function_returned_from_public_function.sol @@ -0,0 +1,7 @@ +// It should not be possible to return internal functions from external functions. +contract C { + function f() public returns (function(uint) internal returns (uint) x) { + } +} +// ---- +// TypeError: (129-169): Internal or recursive type is not allowed for public or external functions. diff --git a/test/libsolidity/syntaxTests/functionTypes/internal_function_type_to_address.sol b/test/libsolidity/syntaxTests/functionTypes/internal_function_type_to_address.sol new file mode 100644 index 00000000..b75a0d43 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/internal_function_type_to_address.sol @@ -0,0 +1,7 @@ +contract C { + function f() public returns (address) { + return address(f); + } +} +// ---- +// TypeError: (72-82): Explicit type conversion not allowed from "function () returns (address)" to "address". diff --git a/test/libsolidity/syntaxTests/functionTypes/payable_internal_function_type.sol b/test/libsolidity/syntaxTests/functionTypes/payable_internal_function_type.sol new file mode 100644 index 00000000..a7cb9d92 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/payable_internal_function_type.sol @@ -0,0 +1,5 @@ +contract C { + function (uint) internal payable returns (uint) x; +} +// ---- +// TypeError: (17-66): Only external function types can be payable. diff --git a/test/libsolidity/syntaxTests/functionTypes/payable_internal_function_type_is_not_fatal.sol b/test/libsolidity/syntaxTests/functionTypes/payable_internal_function_type_is_not_fatal.sol new file mode 100644 index 00000000..5c6dc056 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/payable_internal_function_type_is_not_fatal.sol @@ -0,0 +1,9 @@ +contract C { + function (uint) internal payable returns (uint) x; + + function g() public { + x = g; + } +} +// ---- +// TypeError: (17-66): Only external function types can be payable. diff --git a/test/libsolidity/syntaxTests/functionTypes/private_function_type.sol b/test/libsolidity/syntaxTests/functionTypes/private_function_type.sol new file mode 100644 index 00000000..9d4f0a09 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/private_function_type.sol @@ -0,0 +1,7 @@ +contract C { + function f() public { + function(uint) private returns (uint) x; + } +} +// ---- +// TypeError: (47-86): Invalid visibility, can only be "external" or "internal". diff --git a/test/libsolidity/syntaxTests/functionTypes/public_function_type.sol b/test/libsolidity/syntaxTests/functionTypes/public_function_type.sol new file mode 100644 index 00000000..756766d3 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/public_function_type.sol @@ -0,0 +1,7 @@ +contract C { + function f() public { + function(uint) public returns (uint) x; + } +} +// ---- +// TypeError: (47-85): Invalid visibility, can only be "external" or "internal". diff --git a/test/libsolidity/syntaxTests/functionTypes/valid_function_type_variables.sol b/test/libsolidity/syntaxTests/functionTypes/valid_function_type_variables.sol new file mode 100644 index 00000000..10c6767c --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/valid_function_type_variables.sol @@ -0,0 +1,23 @@ +contract test { + function fa(uint) {} + function fb(uint) internal {} + function fc(uint) internal {} + function fd(uint) external {} + function fe(uint) external {} + function ff(uint) internal {} + function fg(uint) internal pure {} + function fh(uint) pure internal {} + + function(uint) a = fa; + function(uint) internal b = fb; // (explicit internal applies to the function type) + function(uint) internal internal c = fc; + function(uint) external d = this.fd; + function(uint) external internal e = this.fe; + function(uint) internal public f = ff; + function(uint) internal pure public g = fg; + function(uint) pure internal public h = fh; +} +// ---- +// TypeError: (545-582): Internal or recursive type is not allowed for public state variables. +// TypeError: (588-630): Internal or recursive type is not allowed for public state variables. +// TypeError: (636-678): Internal or recursive type is not allowed for public state variables. diff --git a/test/libsolidity/syntaxTests/functionTypes/warn_function_type_parameters_with_names.sol b/test/libsolidity/syntaxTests/functionTypes/warn_function_type_parameters_with_names.sol new file mode 100644 index 00000000..072c7eb7 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/warn_function_type_parameters_with_names.sol @@ -0,0 +1,5 @@ +contract C { + function(uint a) f; +} +// ---- +// Warning: (26-32): Naming function type parameters is deprecated. diff --git a/test/libsolidity/syntaxTests/functionTypes/warn_function_type_return_parameters_with_names.sol b/test/libsolidity/syntaxTests/functionTypes/warn_function_type_return_parameters_with_names.sol new file mode 100644 index 00000000..67a74e54 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/warn_function_type_return_parameters_with_names.sol @@ -0,0 +1,5 @@ +contract C { + function(uint) returns (bool ret) f; +} +// ---- +// Warning: (41-49): Naming function type return parameters is deprecated. diff --git a/test/libsolidity/syntaxTests/inheritance/allow_empty_duplicated_super_constructor_call.sol b/test/libsolidity/syntaxTests/inheritance/allow_empty_duplicated_super_constructor_call.sol new file mode 100644 index 00000000..ce9d5f5f --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/allow_empty_duplicated_super_constructor_call.sol @@ -0,0 +1,2 @@ +contract A { constructor() public { } } +contract B is A { constructor() A() public { } } diff --git a/test/libsolidity/syntaxTests/inheritance/base_arguments_empty_parentheses.sol b/test/libsolidity/syntaxTests/inheritance/base_arguments_empty_parentheses.sol new file mode 100644 index 00000000..0b18b995 --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/base_arguments_empty_parentheses.sol @@ -0,0 +1,7 @@ +contract Base { + constructor(uint) public {} +} +contract Derived is Base(2) { } +contract Derived2 is Base(), Derived() { } +// ---- +// Warning: (101-107): Wrong argument count for constructor call: 0 arguments given but expected 1. diff --git a/test/libsolidity/syntaxTests/inheritance/base_arguments_empty_parentheses_V050.sol b/test/libsolidity/syntaxTests/inheritance/base_arguments_empty_parentheses_V050.sol new file mode 100644 index 00000000..db04ab8c --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/base_arguments_empty_parentheses_V050.sol @@ -0,0 +1,9 @@ +pragma experimental "v0.5.0"; + +contract Base { + constructor(uint) public {} +} +contract Derived is Base(2) { } +contract Derived2 is Base(), Derived() { } +// ---- +// TypeError: (132-138): Wrong argument count for constructor call: 0 arguments given but expected 1. diff --git a/test/libsolidity/syntaxTests/inheritance/base_arguments_multiple_inheritance.sol b/test/libsolidity/syntaxTests/inheritance/base_arguments_multiple_inheritance.sol new file mode 100644 index 00000000..015b33e5 --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/base_arguments_multiple_inheritance.sol @@ -0,0 +1,9 @@ +contract Base { + constructor(uint) public { } +} +contract Base1 is Base(3) {} +contract Derived is Base, Base1 { + constructor(uint i) Base(i) public {} +} +// ---- +// Warning: (138-145): Base constructor arguments given twice. diff --git a/test/libsolidity/syntaxTests/inheritance/base_arguments_no_parentheses.sol b/test/libsolidity/syntaxTests/inheritance/base_arguments_no_parentheses.sol new file mode 100644 index 00000000..24cca8f0 --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/base_arguments_no_parentheses.sol @@ -0,0 +1,5 @@ +contract Base { + constructor(uint) public {} +} +contract Derived is Base(2) { } +contract Derived2 is Base, Derived {} diff --git a/test/libsolidity/syntaxTests/inheritance/disallow_modifier_style_without_parentheses.sol b/test/libsolidity/syntaxTests/inheritance/disallow_modifier_style_without_parentheses.sol new file mode 100644 index 00000000..6cf68d2a --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/disallow_modifier_style_without_parentheses.sol @@ -0,0 +1,4 @@ +contract A { constructor() public { } } +contract B is A { constructor() A public { } } +// ---- +// Warning: (72-73): Modifier-style base constructor call without arguments. diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor.sol new file mode 100644 index 00000000..24cff54d --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor.sol @@ -0,0 +1,5 @@ +contract A { constructor(uint) public { } } +contract B is A(2) { constructor() public { } } +contract C is B { constructor() A(3) public { } } +// ---- +// Warning: (125-129): Base constructor arguments given twice. diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor_V050.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor_V050.sol new file mode 100644 index 00000000..8d5df5bf --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/ancestor_V050.sol @@ -0,0 +1,7 @@ +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.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base.sol new file mode 100644 index 00000000..9ceaea5e --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base.sol @@ -0,0 +1,4 @@ +contract A { constructor(uint) public { } } +contract B is A(2) { constructor() A(3) public { } } +// ---- +// Warning: (79-83): 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 new file mode 100644 index 00000000..f9325f99 --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_V050.sol @@ -0,0 +1,6 @@ +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/inheritance/duplicated_constructor_call/base_multi.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi.sol new file mode 100644 index 00000000..e5c2aa36 --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi.sol @@ -0,0 +1,7 @@ +contract C { constructor(uint) public {} } +contract A is C(2) {} +contract B is C(2) {} +contract D is A, B { constructor() C(3) public {} } +// ---- +// Warning: (122-126): Base constructor arguments given twice. +// Warning: (122-126): Base constructor arguments given twice. diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor.sol new file mode 100644 index 00000000..1abf2992 --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor.sol @@ -0,0 +1,6 @@ +contract C { constructor(uint) public {} } +contract A is C(2) {} +contract B is C(2) {} +contract D is A, B {} +// ---- +// Warning: (87-108): Base constructor arguments given twice. diff --git a/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor_modifier_style.sol b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor_modifier_style.sol new file mode 100644 index 00000000..e15242db --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/duplicated_constructor_call/base_multi_no_constructor_modifier_style.sol @@ -0,0 +1,6 @@ +contract C { constructor(uint) public {} } +contract A is C { constructor() C(2) public {} } +contract B is C { constructor() C(2) public {} } +contract D is A, B { } +// ---- +// Warning: (141-163): Base constructor arguments given twice. diff --git a/test/libsolidity/syntaxTests/inheritance/too_few_base_arguments.sol b/test/libsolidity/syntaxTests/inheritance/too_few_base_arguments.sol new file mode 100644 index 00000000..c55c41f2 --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/too_few_base_arguments.sol @@ -0,0 +1,10 @@ +contract Base { + constructor(uint, uint) public {} +} +contract Derived is Base(2) { } +contract Derived2 is Base { + constructor() Base(2) public { } +} +// ---- +// TypeError: (74-81): Wrong argument count for constructor call: 1 arguments given but expected 2. +// TypeError: (130-137): Wrong argument count for modifier invocation: 1 arguments given but expected 2. diff --git a/test/libsolidity/syntaxTests/literalOperations/division_by_zero.sol b/test/libsolidity/syntaxTests/literalOperations/division_by_zero.sol new file mode 100644 index 00000000..b52b4c51 --- /dev/null +++ b/test/libsolidity/syntaxTests/literalOperations/division_by_zero.sol @@ -0,0 +1,5 @@ +contract C { + uint constant a = 1 / 0; +} +// ---- +// TypeError: (35-40): Operator / not compatible with types int_const 1 and int_const 0 diff --git a/test/libsolidity/syntaxTests/literalOperations/division_by_zero_complex.sol b/test/libsolidity/syntaxTests/literalOperations/division_by_zero_complex.sol new file mode 100644 index 00000000..8cc3b6f2 --- /dev/null +++ b/test/libsolidity/syntaxTests/literalOperations/division_by_zero_complex.sol @@ -0,0 +1,5 @@ +contract C { + uint constant a = 1 / ((1+3)-4); +} +// ---- +// TypeError: (35-48): Operator / not compatible with types int_const 1 and int_const 0 diff --git a/test/libsolidity/syntaxTests/literalOperations/mod_zero.sol b/test/libsolidity/syntaxTests/literalOperations/mod_zero.sol new file mode 100644 index 00000000..1bbbc3fc --- /dev/null +++ b/test/libsolidity/syntaxTests/literalOperations/mod_zero.sol @@ -0,0 +1,5 @@ +contract C { + uint constant b3 = 1 % 0; +} +// ---- +// TypeError: (36-41): Operator % not compatible with types int_const 1 and int_const 0 diff --git a/test/libsolidity/syntaxTests/literalOperations/mod_zero_complex.sol b/test/libsolidity/syntaxTests/literalOperations/mod_zero_complex.sol new file mode 100644 index 00000000..4899cac3 --- /dev/null +++ b/test/libsolidity/syntaxTests/literalOperations/mod_zero_complex.sol @@ -0,0 +1,5 @@ +contract C { + uint constant b3 = 1 % (-4+((2)*2)); +} +// ---- +// TypeError: (36-52): Operator % not compatible with types int_const 1 and int_const 0 diff --git a/test/libsolidity/syntaxTests/literal_comparisons.sol b/test/libsolidity/syntaxTests/literal_comparisons.sol new file mode 100644 index 00000000..dd2afcaa --- /dev/null +++ b/test/libsolidity/syntaxTests/literal_comparisons.sol @@ -0,0 +1,7 @@ +contract test { + function f(int8 x) public pure { + if (x == 1) {} + if (1 == x) {} + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/modifiers/base_constructor_double_invocation.sol b/test/libsolidity/syntaxTests/modifiers/base_constructor_double_invocation.sol new file mode 100644 index 00000000..bdbab5d8 --- /dev/null +++ b/test/libsolidity/syntaxTests/modifiers/base_constructor_double_invocation.sol @@ -0,0 +1,7 @@ +contract C { constructor(uint a) public {} } +contract B is C { + constructor() C(2) C(2) public {} +} +// ---- +// Warning: (81-85): Base constructor arguments given twice. +// DeclarationError: (86-90): Base constructor already provided. diff --git a/test/libsolidity/syntaxTests/modifiers/constructor_call_invalid_arg_count.sol b/test/libsolidity/syntaxTests/modifiers/constructor_call_invalid_arg_count.sol new file mode 100644 index 00000000..4a2b5c4a --- /dev/null +++ b/test/libsolidity/syntaxTests/modifiers/constructor_call_invalid_arg_count.sol @@ -0,0 +1,9 @@ +// This caused a segfault in an earlier version +contract C { + constructor() public {} +} +contract D is C { + constructor() C(5) public {} +} +// ---- +// TypeError: (127-131): Wrong argument count for modifier invocation: 1 arguments given but expected 0. diff --git a/test/libsolidity/syntaxTests/modifiers/function_modifier_double_invocation.sol b/test/libsolidity/syntaxTests/modifiers/function_modifier_double_invocation.sol new file mode 100644 index 00000000..75624192 --- /dev/null +++ b/test/libsolidity/syntaxTests/modifiers/function_modifier_double_invocation.sol @@ -0,0 +1,4 @@ +contract B { + function f(uint x) mod(x) mod(2) public pure { } + modifier mod(uint a) { if (a > 0) _; } +} diff --git a/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation.sol b/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation.sol new file mode 100644 index 00000000..e15fcf49 --- /dev/null +++ b/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation.sol @@ -0,0 +1,5 @@ +contract B { + function f() mod1(2, true) mod2("0123456") pure public { } + modifier mod1(uint a, bool b) { if (b) _; } + modifier mod2(bytes7 a) { while (a == "1234567") _; } +} diff --git a/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_local_variables.sol b/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_local_variables.sol new file mode 100644 index 00000000..00031924 --- /dev/null +++ b/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_local_variables.sol @@ -0,0 +1,4 @@ +contract B { + function f() mod(x) pure public { uint x = 7; } + modifier mod(uint a) { if (a > 0) _; } +} diff --git a/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_local_variables050.sol b/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_local_variables050.sol new file mode 100644 index 00000000..c19ccf2c --- /dev/null +++ b/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_local_variables050.sol @@ -0,0 +1,7 @@ +pragma experimental "v0.5.0"; +contract B { + function f() mod(x) pure public { uint x = 7; } + modifier mod(uint a) { if (a > 0) _; } +} +// ---- +// DeclarationError: (64-65): Undeclared identifier. diff --git a/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_parameters.sol b/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_parameters.sol new file mode 100644 index 00000000..de2a8f48 --- /dev/null +++ b/test/libsolidity/syntaxTests/modifiers/function_modifier_invocation_parameters.sol @@ -0,0 +1,5 @@ +contract B { + function f(uint8 a) mod1(a, true) mod2(r) pure public returns (bytes7 r) { } + modifier mod1(uint a, bool b) { if (b) _; } + modifier mod2(bytes7 a) { while (a == "1234567") _; } +} diff --git a/test/libsolidity/syntaxTests/modifiers/function_overrides_modifier.sol b/test/libsolidity/syntaxTests/modifiers/function_overrides_modifier.sol new file mode 100644 index 00000000..a64c2790 --- /dev/null +++ b/test/libsolidity/syntaxTests/modifiers/function_overrides_modifier.sol @@ -0,0 +1,5 @@ +contract A { function mod(uint a) public { } } +contract B is A { modifier mod(uint a) { _; } } +// ---- +// DeclarationError: (65-92): Identifier already declared. +// TypeError: (65-92): Override changes function to modifier. diff --git a/test/libsolidity/syntaxTests/modifiers/illegal_modifier_override.sol b/test/libsolidity/syntaxTests/modifiers/illegal_modifier_override.sol new file mode 100644 index 00000000..958be686 --- /dev/null +++ b/test/libsolidity/syntaxTests/modifiers/illegal_modifier_override.sol @@ -0,0 +1,4 @@ +contract A { modifier mod(uint a) { _; } } +contract B is A { modifier mod(uint8 a) { _; } } +// ---- +// TypeError: (61-89): Override changes modifier signature. diff --git a/test/libsolidity/syntaxTests/modifiers/invalid_function_modifier_type.sol b/test/libsolidity/syntaxTests/modifiers/invalid_function_modifier_type.sol new file mode 100644 index 00000000..c1e3108b --- /dev/null +++ b/test/libsolidity/syntaxTests/modifiers/invalid_function_modifier_type.sol @@ -0,0 +1,6 @@ +contract B { + function f() mod1(true) public { } + modifier mod1(uint a) { if (a > 0) _; } +} +// ---- +// TypeError: (35-39): Invalid type for argument in modifier invocation. Invalid implicit conversion from bool to uint256 requested. diff --git a/test/libsolidity/syntaxTests/modifiers/legal_modifier_override.sol b/test/libsolidity/syntaxTests/modifiers/legal_modifier_override.sol new file mode 100644 index 00000000..51c3fd80 --- /dev/null +++ b/test/libsolidity/syntaxTests/modifiers/legal_modifier_override.sol @@ -0,0 +1,2 @@ +contract A { modifier mod(uint a) { _; } } +contract B is A { modifier mod(uint a) { _; } } diff --git a/test/libsolidity/syntaxTests/modifiers/modifier_overrides_function.sol b/test/libsolidity/syntaxTests/modifiers/modifier_overrides_function.sol new file mode 100644 index 00000000..a43646c3 --- /dev/null +++ b/test/libsolidity/syntaxTests/modifiers/modifier_overrides_function.sol @@ -0,0 +1,5 @@ +contract A { modifier mod(uint a) { _; } } +contract B is A { function mod(uint a) public { } } +// ---- +// DeclarationError: (61-92): Identifier already declared. +// TypeError: (13-40): Override changes modifier to function. diff --git a/test/libsolidity/syntaxTests/modifiers/modifier_returns_value.sol b/test/libsolidity/syntaxTests/modifiers/modifier_returns_value.sol new file mode 100644 index 00000000..d22e836c --- /dev/null +++ b/test/libsolidity/syntaxTests/modifiers/modifier_returns_value.sol @@ -0,0 +1,6 @@ +contract A { + function f(uint a) mod(2) public returns (uint r) { } + modifier mod(uint a) { _; return 7; } +} +// ---- +// TypeError: (101-109): Return arguments not allowed. diff --git a/test/libsolidity/syntaxTests/modifiers/modifier_without_underscore.sol b/test/libsolidity/syntaxTests/modifiers/modifier_without_underscore.sol new file mode 100644 index 00000000..6198d3c5 --- /dev/null +++ b/test/libsolidity/syntaxTests/modifiers/modifier_without_underscore.sol @@ -0,0 +1,5 @@ +contract test { + modifier m() {} +} +// ---- +// SyntaxError: (33-35): Modifier body does not contain '_'. diff --git a/test/libsolidity/syntaxTests/modifiers/modifiers_on_abstract_functions_050.sol b/test/libsolidity/syntaxTests/modifiers/modifiers_on_abstract_functions_050.sol new file mode 100644 index 00000000..af1babbc --- /dev/null +++ b/test/libsolidity/syntaxTests/modifiers/modifiers_on_abstract_functions_050.sol @@ -0,0 +1,10 @@ +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/modifiers/modifiers_on_abstract_functions_no_parser_error.sol b/test/libsolidity/syntaxTests/modifiers/modifiers_on_abstract_functions_no_parser_error.sol new file mode 100644 index 00000000..e18c5cf9 --- /dev/null +++ b/test/libsolidity/syntaxTests/modifiers/modifiers_on_abstract_functions_no_parser_error.sol @@ -0,0 +1,13 @@ +// Previous versions of Solidity turned this +// into a parser error (they wrongly recognized +// these functions as state variables of +// function type). +contract C +{ + modifier only_owner() { _; } + function foo() only_owner public; + function bar() public only_owner; +} +// ---- +// Warning: (203-236): Modifiers of functions without implementation are ignored. +// Warning: (241-274): Modifiers of functions without implementation are ignored. diff --git a/test/libsolidity/syntaxTests/more_than_256_declarationerrors.sol b/test/libsolidity/syntaxTests/more_than_256_declarationerrors.sol new file mode 100644 index 00000000..2d75f29b --- /dev/null +++ b/test/libsolidity/syntaxTests/more_than_256_declarationerrors.sol @@ -0,0 +1,524 @@ +contract C { + function f() { + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + b = 5; + } +} +// ---- +// DeclarationError: (34-35): Undeclared identifier. +// DeclarationError: (45-46): Undeclared identifier. +// DeclarationError: (56-57): Undeclared identifier. +// DeclarationError: (67-68): Undeclared identifier. +// DeclarationError: (78-79): Undeclared identifier. +// DeclarationError: (89-90): Undeclared identifier. +// DeclarationError: (100-101): Undeclared identifier. +// DeclarationError: (111-112): Undeclared identifier. +// DeclarationError: (122-123): Undeclared identifier. +// DeclarationError: (133-134): Undeclared identifier. +// DeclarationError: (144-145): Undeclared identifier. +// DeclarationError: (155-156): Undeclared identifier. +// DeclarationError: (166-167): Undeclared identifier. +// DeclarationError: (177-178): Undeclared identifier. +// DeclarationError: (188-189): Undeclared identifier. +// DeclarationError: (199-200): Undeclared identifier. +// DeclarationError: (210-211): Undeclared identifier. +// DeclarationError: (221-222): Undeclared identifier. +// DeclarationError: (232-233): Undeclared identifier. +// DeclarationError: (243-244): Undeclared identifier. +// DeclarationError: (254-255): Undeclared identifier. +// DeclarationError: (265-266): Undeclared identifier. +// DeclarationError: (276-277): Undeclared identifier. +// DeclarationError: (287-288): Undeclared identifier. +// DeclarationError: (298-299): Undeclared identifier. +// DeclarationError: (309-310): Undeclared identifier. +// DeclarationError: (320-321): Undeclared identifier. +// DeclarationError: (331-332): Undeclared identifier. +// DeclarationError: (342-343): Undeclared identifier. +// DeclarationError: (353-354): Undeclared identifier. +// DeclarationError: (364-365): Undeclared identifier. +// DeclarationError: (375-376): Undeclared identifier. +// DeclarationError: (386-387): Undeclared identifier. +// DeclarationError: (397-398): Undeclared identifier. +// DeclarationError: (408-409): Undeclared identifier. +// DeclarationError: (419-420): Undeclared identifier. +// DeclarationError: (430-431): Undeclared identifier. +// DeclarationError: (441-442): Undeclared identifier. +// DeclarationError: (452-453): Undeclared identifier. +// DeclarationError: (463-464): Undeclared identifier. +// DeclarationError: (474-475): Undeclared identifier. +// DeclarationError: (485-486): Undeclared identifier. +// DeclarationError: (496-497): Undeclared identifier. +// DeclarationError: (507-508): Undeclared identifier. +// DeclarationError: (518-519): Undeclared identifier. +// DeclarationError: (529-530): Undeclared identifier. +// DeclarationError: (540-541): Undeclared identifier. +// DeclarationError: (551-552): Undeclared identifier. +// DeclarationError: (562-563): Undeclared identifier. +// DeclarationError: (573-574): Undeclared identifier. +// DeclarationError: (584-585): Undeclared identifier. +// DeclarationError: (595-596): Undeclared identifier. +// DeclarationError: (606-607): Undeclared identifier. +// DeclarationError: (617-618): Undeclared identifier. +// DeclarationError: (628-629): Undeclared identifier. +// DeclarationError: (639-640): Undeclared identifier. +// DeclarationError: (650-651): Undeclared identifier. +// DeclarationError: (661-662): Undeclared identifier. +// DeclarationError: (672-673): Undeclared identifier. +// DeclarationError: (683-684): Undeclared identifier. +// DeclarationError: (694-695): Undeclared identifier. +// DeclarationError: (705-706): Undeclared identifier. +// DeclarationError: (716-717): Undeclared identifier. +// DeclarationError: (727-728): Undeclared identifier. +// DeclarationError: (738-739): Undeclared identifier. +// DeclarationError: (749-750): Undeclared identifier. +// DeclarationError: (760-761): Undeclared identifier. +// DeclarationError: (771-772): Undeclared identifier. +// DeclarationError: (782-783): Undeclared identifier. +// DeclarationError: (793-794): Undeclared identifier. +// DeclarationError: (804-805): Undeclared identifier. +// DeclarationError: (815-816): Undeclared identifier. +// DeclarationError: (826-827): Undeclared identifier. +// DeclarationError: (837-838): Undeclared identifier. +// DeclarationError: (848-849): Undeclared identifier. +// DeclarationError: (859-860): Undeclared identifier. +// DeclarationError: (870-871): Undeclared identifier. +// DeclarationError: (881-882): Undeclared identifier. +// DeclarationError: (892-893): Undeclared identifier. +// DeclarationError: (903-904): Undeclared identifier. +// DeclarationError: (914-915): Undeclared identifier. +// DeclarationError: (925-926): Undeclared identifier. +// DeclarationError: (936-937): Undeclared identifier. +// DeclarationError: (947-948): Undeclared identifier. +// DeclarationError: (958-959): Undeclared identifier. +// DeclarationError: (969-970): Undeclared identifier. +// DeclarationError: (980-981): Undeclared identifier. +// DeclarationError: (991-992): Undeclared identifier. +// DeclarationError: (1002-1003): Undeclared identifier. +// DeclarationError: (1013-1014): Undeclared identifier. +// DeclarationError: (1024-1025): Undeclared identifier. +// DeclarationError: (1035-1036): Undeclared identifier. +// DeclarationError: (1046-1047): Undeclared identifier. +// DeclarationError: (1057-1058): Undeclared identifier. +// DeclarationError: (1068-1069): Undeclared identifier. +// DeclarationError: (1079-1080): Undeclared identifier. +// DeclarationError: (1090-1091): Undeclared identifier. +// DeclarationError: (1101-1102): Undeclared identifier. +// DeclarationError: (1112-1113): Undeclared identifier. +// DeclarationError: (1123-1124): Undeclared identifier. +// DeclarationError: (1134-1135): Undeclared identifier. +// DeclarationError: (1145-1146): Undeclared identifier. +// DeclarationError: (1156-1157): Undeclared identifier. +// DeclarationError: (1167-1168): Undeclared identifier. +// DeclarationError: (1178-1179): Undeclared identifier. +// DeclarationError: (1189-1190): Undeclared identifier. +// DeclarationError: (1200-1201): Undeclared identifier. +// DeclarationError: (1211-1212): Undeclared identifier. +// DeclarationError: (1222-1223): Undeclared identifier. +// DeclarationError: (1233-1234): Undeclared identifier. +// DeclarationError: (1244-1245): Undeclared identifier. +// DeclarationError: (1255-1256): Undeclared identifier. +// DeclarationError: (1266-1267): Undeclared identifier. +// DeclarationError: (1277-1278): Undeclared identifier. +// DeclarationError: (1288-1289): Undeclared identifier. +// DeclarationError: (1299-1300): Undeclared identifier. +// DeclarationError: (1310-1311): Undeclared identifier. +// DeclarationError: (1321-1322): Undeclared identifier. +// DeclarationError: (1332-1333): Undeclared identifier. +// DeclarationError: (1343-1344): Undeclared identifier. +// DeclarationError: (1354-1355): Undeclared identifier. +// DeclarationError: (1365-1366): Undeclared identifier. +// DeclarationError: (1376-1377): Undeclared identifier. +// DeclarationError: (1387-1388): Undeclared identifier. +// DeclarationError: (1398-1399): Undeclared identifier. +// DeclarationError: (1409-1410): Undeclared identifier. +// DeclarationError: (1420-1421): Undeclared identifier. +// DeclarationError: (1431-1432): Undeclared identifier. +// DeclarationError: (1442-1443): Undeclared identifier. +// DeclarationError: (1453-1454): Undeclared identifier. +// DeclarationError: (1464-1465): Undeclared identifier. +// DeclarationError: (1475-1476): Undeclared identifier. +// DeclarationError: (1486-1487): Undeclared identifier. +// DeclarationError: (1497-1498): Undeclared identifier. +// DeclarationError: (1508-1509): Undeclared identifier. +// DeclarationError: (1519-1520): Undeclared identifier. +// DeclarationError: (1530-1531): Undeclared identifier. +// DeclarationError: (1541-1542): Undeclared identifier. +// DeclarationError: (1552-1553): Undeclared identifier. +// DeclarationError: (1563-1564): Undeclared identifier. +// DeclarationError: (1574-1575): Undeclared identifier. +// DeclarationError: (1585-1586): Undeclared identifier. +// DeclarationError: (1596-1597): Undeclared identifier. +// DeclarationError: (1607-1608): Undeclared identifier. +// DeclarationError: (1618-1619): Undeclared identifier. +// DeclarationError: (1629-1630): Undeclared identifier. +// DeclarationError: (1640-1641): Undeclared identifier. +// DeclarationError: (1651-1652): Undeclared identifier. +// DeclarationError: (1662-1663): Undeclared identifier. +// DeclarationError: (1673-1674): Undeclared identifier. +// DeclarationError: (1684-1685): Undeclared identifier. +// DeclarationError: (1695-1696): Undeclared identifier. +// DeclarationError: (1706-1707): Undeclared identifier. +// DeclarationError: (1717-1718): Undeclared identifier. +// DeclarationError: (1728-1729): Undeclared identifier. +// DeclarationError: (1739-1740): Undeclared identifier. +// DeclarationError: (1750-1751): Undeclared identifier. +// DeclarationError: (1761-1762): Undeclared identifier. +// DeclarationError: (1772-1773): Undeclared identifier. +// DeclarationError: (1783-1784): Undeclared identifier. +// DeclarationError: (1794-1795): Undeclared identifier. +// DeclarationError: (1805-1806): Undeclared identifier. +// DeclarationError: (1816-1817): Undeclared identifier. +// DeclarationError: (1827-1828): Undeclared identifier. +// DeclarationError: (1838-1839): Undeclared identifier. +// DeclarationError: (1849-1850): Undeclared identifier. +// DeclarationError: (1860-1861): Undeclared identifier. +// DeclarationError: (1871-1872): Undeclared identifier. +// DeclarationError: (1882-1883): Undeclared identifier. +// DeclarationError: (1893-1894): Undeclared identifier. +// DeclarationError: (1904-1905): Undeclared identifier. +// DeclarationError: (1915-1916): Undeclared identifier. +// DeclarationError: (1926-1927): Undeclared identifier. +// DeclarationError: (1937-1938): Undeclared identifier. +// DeclarationError: (1948-1949): Undeclared identifier. +// DeclarationError: (1959-1960): Undeclared identifier. +// DeclarationError: (1970-1971): Undeclared identifier. +// DeclarationError: (1981-1982): Undeclared identifier. +// DeclarationError: (1992-1993): Undeclared identifier. +// DeclarationError: (2003-2004): Undeclared identifier. +// DeclarationError: (2014-2015): Undeclared identifier. +// DeclarationError: (2025-2026): Undeclared identifier. +// DeclarationError: (2036-2037): Undeclared identifier. +// DeclarationError: (2047-2048): Undeclared identifier. +// DeclarationError: (2058-2059): Undeclared identifier. +// DeclarationError: (2069-2070): Undeclared identifier. +// DeclarationError: (2080-2081): Undeclared identifier. +// DeclarationError: (2091-2092): Undeclared identifier. +// DeclarationError: (2102-2103): Undeclared identifier. +// DeclarationError: (2113-2114): Undeclared identifier. +// DeclarationError: (2124-2125): Undeclared identifier. +// DeclarationError: (2135-2136): Undeclared identifier. +// DeclarationError: (2146-2147): Undeclared identifier. +// DeclarationError: (2157-2158): Undeclared identifier. +// DeclarationError: (2168-2169): Undeclared identifier. +// DeclarationError: (2179-2180): Undeclared identifier. +// DeclarationError: (2190-2191): Undeclared identifier. +// DeclarationError: (2201-2202): Undeclared identifier. +// DeclarationError: (2212-2213): Undeclared identifier. +// DeclarationError: (2223-2224): Undeclared identifier. +// DeclarationError: (2234-2235): Undeclared identifier. +// DeclarationError: (2245-2246): Undeclared identifier. +// DeclarationError: (2256-2257): Undeclared identifier. +// DeclarationError: (2267-2268): Undeclared identifier. +// DeclarationError: (2278-2279): Undeclared identifier. +// DeclarationError: (2289-2290): Undeclared identifier. +// DeclarationError: (2300-2301): Undeclared identifier. +// DeclarationError: (2311-2312): Undeclared identifier. +// DeclarationError: (2322-2323): Undeclared identifier. +// DeclarationError: (2333-2334): Undeclared identifier. +// DeclarationError: (2344-2345): Undeclared identifier. +// DeclarationError: (2355-2356): Undeclared identifier. +// DeclarationError: (2366-2367): Undeclared identifier. +// DeclarationError: (2377-2378): Undeclared identifier. +// DeclarationError: (2388-2389): Undeclared identifier. +// DeclarationError: (2399-2400): Undeclared identifier. +// DeclarationError: (2410-2411): Undeclared identifier. +// DeclarationError: (2421-2422): Undeclared identifier. +// DeclarationError: (2432-2433): Undeclared identifier. +// DeclarationError: (2443-2444): Undeclared identifier. +// DeclarationError: (2454-2455): Undeclared identifier. +// DeclarationError: (2465-2466): Undeclared identifier. +// DeclarationError: (2476-2477): Undeclared identifier. +// DeclarationError: (2487-2488): Undeclared identifier. +// DeclarationError: (2498-2499): Undeclared identifier. +// DeclarationError: (2509-2510): Undeclared identifier. +// DeclarationError: (2520-2521): Undeclared identifier. +// DeclarationError: (2531-2532): Undeclared identifier. +// DeclarationError: (2542-2543): Undeclared identifier. +// DeclarationError: (2553-2554): Undeclared identifier. +// DeclarationError: (2564-2565): Undeclared identifier. +// DeclarationError: (2575-2576): Undeclared identifier. +// DeclarationError: (2586-2587): Undeclared identifier. +// DeclarationError: (2597-2598): Undeclared identifier. +// DeclarationError: (2608-2609): Undeclared identifier. +// DeclarationError: (2619-2620): Undeclared identifier. +// DeclarationError: (2630-2631): Undeclared identifier. +// DeclarationError: (2641-2642): Undeclared identifier. +// DeclarationError: (2652-2653): Undeclared identifier. +// DeclarationError: (2663-2664): Undeclared identifier. +// DeclarationError: (2674-2675): Undeclared identifier. +// DeclarationError: (2685-2686): Undeclared identifier. +// DeclarationError: (2696-2697): Undeclared identifier. +// DeclarationError: (2707-2708): Undeclared identifier. +// DeclarationError: (2718-2719): Undeclared identifier. +// DeclarationError: (2729-2730): Undeclared identifier. +// DeclarationError: (2740-2741): Undeclared identifier. +// DeclarationError: (2751-2752): Undeclared identifier. +// DeclarationError: (2762-2763): Undeclared identifier. +// DeclarationError: (2773-2774): Undeclared identifier. +// DeclarationError: (2784-2785): Undeclared identifier. +// DeclarationError: (2795-2796): Undeclared identifier. +// DeclarationError: (2806-2807): Undeclared identifier. +// DeclarationError: (2817-2818): Undeclared identifier. +// DeclarationError: (2828-2829): Undeclared identifier. +// DeclarationError: (2839-2840): Undeclared identifier. +// Warning: There are more than 256 errors. Aborting. diff --git a/test/libsolidity/syntaxTests/more_than_256_syntaxerrors.sol b/test/libsolidity/syntaxTests/more_than_256_syntaxerrors.sol new file mode 100644 index 00000000..2c9b8a42 --- /dev/null +++ b/test/libsolidity/syntaxTests/more_than_256_syntaxerrors.sol @@ -0,0 +1,524 @@ +contract C { + function f() { + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + continue; + } +} +// ---- +// SyntaxError: (34-42): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (48-56): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (62-70): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (76-84): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (90-98): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (104-112): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (118-126): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (132-140): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (146-154): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (160-168): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (174-182): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (188-196): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (202-210): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (216-224): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (230-238): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (244-252): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (258-266): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (272-280): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (286-294): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (300-308): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (314-322): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (328-336): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (342-350): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (356-364): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (370-378): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (384-392): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (398-406): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (412-420): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (426-434): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (440-448): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (454-462): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (468-476): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (482-490): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (496-504): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (510-518): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (524-532): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (538-546): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (552-560): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (566-574): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (580-588): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (594-602): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (608-616): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (622-630): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (636-644): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (650-658): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (664-672): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (678-686): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (692-700): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (706-714): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (720-728): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (734-742): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (748-756): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (762-770): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (776-784): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (790-798): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (804-812): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (818-826): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (832-840): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (846-854): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (860-868): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (874-882): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (888-896): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (902-910): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (916-924): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (930-938): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (944-952): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (958-966): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (972-980): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (986-994): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1000-1008): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1014-1022): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1028-1036): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1042-1050): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1056-1064): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1070-1078): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1084-1092): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1098-1106): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1112-1120): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1126-1134): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1140-1148): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1154-1162): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1168-1176): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1182-1190): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1196-1204): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1210-1218): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1224-1232): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1238-1246): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1252-1260): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1266-1274): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1280-1288): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1294-1302): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1308-1316): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1322-1330): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1336-1344): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1350-1358): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1364-1372): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1378-1386): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1392-1400): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1406-1414): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1420-1428): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1434-1442): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1448-1456): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1462-1470): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1476-1484): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1490-1498): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1504-1512): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1518-1526): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1532-1540): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1546-1554): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1560-1568): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1574-1582): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1588-1596): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1602-1610): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1616-1624): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1630-1638): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1644-1652): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1658-1666): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1672-1680): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1686-1694): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1700-1708): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1714-1722): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1728-1736): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1742-1750): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1756-1764): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1770-1778): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1784-1792): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1798-1806): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1812-1820): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1826-1834): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1840-1848): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1854-1862): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1868-1876): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1882-1890): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1896-1904): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1910-1918): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1924-1932): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1938-1946): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1952-1960): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1966-1974): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1980-1988): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (1994-2002): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2008-2016): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2022-2030): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2036-2044): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2050-2058): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2064-2072): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2078-2086): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2092-2100): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2106-2114): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2120-2128): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2134-2142): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2148-2156): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2162-2170): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2176-2184): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2190-2198): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2204-2212): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2218-2226): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2232-2240): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2246-2254): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2260-2268): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2274-2282): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2288-2296): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2302-2310): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2316-2324): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2330-2338): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2344-2352): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2358-2366): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2372-2380): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2386-2394): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2400-2408): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2414-2422): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2428-2436): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2442-2450): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2456-2464): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2470-2478): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2484-2492): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2498-2506): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2512-2520): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2526-2534): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2540-2548): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2554-2562): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2568-2576): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2582-2590): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2596-2604): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2610-2618): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2624-2632): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2638-2646): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2652-2660): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2666-2674): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2680-2688): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2694-2702): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2708-2716): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2722-2730): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2736-2744): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2750-2758): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2764-2772): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2778-2786): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2792-2800): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2806-2814): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2820-2828): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2834-2842): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2848-2856): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2862-2870): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2876-2884): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2890-2898): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2904-2912): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2918-2926): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2932-2940): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2946-2954): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2960-2968): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2974-2982): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (2988-2996): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3002-3010): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3016-3024): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3030-3038): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3044-3052): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3058-3066): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3072-3080): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3086-3094): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3100-3108): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3114-3122): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3128-3136): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3142-3150): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3156-3164): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3170-3178): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3184-3192): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3198-3206): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3212-3220): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3226-3234): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3240-3248): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3254-3262): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3268-3276): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3282-3290): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3296-3304): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3310-3318): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3324-3332): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3338-3346): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3352-3360): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3366-3374): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3380-3388): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3394-3402): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3408-3416): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3422-3430): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3436-3444): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3450-3458): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3464-3472): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3478-3486): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3492-3500): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3506-3514): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3520-3528): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3534-3542): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3548-3556): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3562-3570): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3576-3584): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3590-3598): "continue" has to be in a "for" or "while" loop. +// SyntaxError: (3604-3612): "continue" has to be in a "for" or "while" loop. +// Warning: There are more than 256 errors. Aborting. diff --git a/test/libsolidity/syntaxTests/parsing/constructor_allowed_this.sol b/test/libsolidity/syntaxTests/parsing/constructor_allowed_this.sol new file mode 100644 index 00000000..9f714aea --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/constructor_allowed_this.sol @@ -0,0 +1,28 @@ +contract A { + function a() public pure { + } +} +contract B { + constructor(address) public { + } + function b(address) public returns (A) { + return new A(); + } +} +contract C { + B m_b; + C m_c; + constructor(C other_c) public { + m_c = other_c; + m_b = new B(this); + m_b.b(this).a(); + g(this).f(); + other_c.f(); + m_c.f(); + } + function f() public pure { + } + function g(C) public view returns (C) { + return m_c; + } +} diff --git a/test/libsolidity/syntaxTests/parsing/constructor_super.sol b/test/libsolidity/syntaxTests/parsing/constructor_super.sol new file mode 100644 index 00000000..fa1be187 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/constructor_super.sol @@ -0,0 +1,10 @@ +contract A { + function x() pure internal {} +} + +contract B is A { + constructor() public { + // used to trigger warning about using ``this`` in constructor + super.x(); + } +} diff --git a/test/libsolidity/syntaxTests/parsing/missing_variable_name_in_declaration.sol b/test/libsolidity/syntaxTests/parsing/missing_variable_name_in_declaration.sol new file mode 100644 index 00000000..fd3067e3 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/missing_variable_name_in_declaration.sol @@ -0,0 +1,5 @@ +contract test { + uint256 ; +} +// ---- +// ParserError: (28-28): Expected identifier, got 'Semicolon' diff --git a/test/libsolidity/syntaxTests/parsing/return_var.sol b/test/libsolidity/syntaxTests/parsing/return_var.sol new file mode 100644 index 00000000..47ac9ef0 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/return_var.sol @@ -0,0 +1,25 @@ +contract C { + function f() returns(var) {} + function f() returns(var x) {} + function f() returns(var x, uint y) {} + function f() returns(uint x, var y) {} + function f() returns(var x, var y) {} + function f() public pure returns (var storage) {} + function f() public pure returns (var storage x) {} + function f() public pure returns (var storage x, var storage y) {} +} +// ---- +// ParserError: (38-38): Expected explicit type name. +// ParserError: (71-71): Expected explicit type name. +// ParserError: (106-106): Expected explicit type name. +// ParserError: (157-157): Expected explicit type name. +// ParserError: (192-192): Expected explicit type name. +// ParserError: (199-199): Expected explicit type name. +// ParserError: (247-247): Expected explicit type name. +// ParserError: (251-251): Location specifier needs explicit type name. +// ParserError: (301-301): Expected explicit type name. +// ParserError: (305-305): Location specifier needs explicit type name. +// ParserError: (357-357): Expected explicit type name. +// ParserError: (361-361): Location specifier needs explicit type name. +// ParserError: (372-372): Expected explicit type name. +// ParserError: (376-376): Location specifier needs explicit type name. diff --git a/test/libsolidity/syntaxTests/parsing/smoke_test.sol b/test/libsolidity/syntaxTests/parsing/smoke_test.sol new file mode 100644 index 00000000..d328b167 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/smoke_test.sol @@ -0,0 +1,4 @@ +contract test { + uint256 stateVariable1; +} +// ---- diff --git a/test/libsolidity/syntaxTests/parsing/var_in_function_arguments.sol b/test/libsolidity/syntaxTests/parsing/var_in_function_arguments.sol new file mode 100644 index 00000000..e041247d --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/var_in_function_arguments.sol @@ -0,0 +1,25 @@ +contract C { + function f(var) public pure {} + function f(var x) public pure {} + function f(var x, var y) public pure {} + function f(uint x, var y) public pure {} + function f(var x, uint y) public pure {} + function f(var storage) public pure {} + function f(var storage x) public pure {} + function f(var storage x, var storage y) public pure {} +} +// ---- +// ParserError: (28-28): Expected explicit type name. +// ParserError: (63-63): Expected explicit type name. +// ParserError: (100-100): Expected explicit type name. +// ParserError: (107-107): Expected explicit type name. +// ParserError: (152-152): Expected explicit type name. +// ParserError: (189-189): Expected explicit type name. +// ParserError: (234-234): Expected explicit type name. +// ParserError: (238-238): Location specifier needs explicit type name. +// ParserError: (277-277): Expected explicit type name. +// ParserError: (281-281): Location specifier needs explicit type name. +// ParserError: (322-322): Expected explicit type name. +// ParserError: (326-326): Location specifier needs explicit type name. +// ParserError: (337-337): Expected explicit type name. +// ParserError: (341-341): Location specifier needs explicit type name. diff --git a/test/libsolidity/syntaxTests/parsing/var_storage_var.sol b/test/libsolidity/syntaxTests/parsing/var_storage_var.sol new file mode 100644 index 00000000..431d4ca5 --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/var_storage_var.sol @@ -0,0 +1,5 @@ +contract C { + var a; +} +// ---- +// ParserError: (17-17): Function, variable, struct or modifier declaration expected. diff --git a/test/libsolidity/syntaxTests/scoping/double_function_declaration.sol b/test/libsolidity/syntaxTests/scoping/double_function_declaration.sol new file mode 100644 index 00000000..dfd67aaa --- /dev/null +++ b/test/libsolidity/syntaxTests/scoping/double_function_declaration.sol @@ -0,0 +1,6 @@ +contract test { + function fun() public { } + function fun() public { } +} +// ---- +// DeclarationError: (20-45): Function with same name and arguments defined twice. diff --git a/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope.sol b/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope.sol new file mode 100644 index 00000000..d90ec2d7 --- /dev/null +++ b/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope.sol @@ -0,0 +1,8 @@ +contract test { + function f() pure public { + { uint x; } + { uint x; } + } +} +// ---- +// DeclarationError: (77-83): Identifier already declared. diff --git a/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_050.sol b/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_050.sol new file mode 100644 index 00000000..06bfe7be --- /dev/null +++ b/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_050.sol @@ -0,0 +1,10 @@ +pragma experimental "v0.5.0"; +contract test { + function f() pure public { + { uint x; } + { uint x; } + } +} +// ---- +// Warning: (87-93): Unused local variable. +// Warning: (107-113): Unused local variable. diff --git a/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_activation.sol b/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_activation.sol new file mode 100644 index 00000000..1a5ff2f9 --- /dev/null +++ b/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_activation.sol @@ -0,0 +1,8 @@ +contract test { + function f() pure public { + { uint x; } + uint x; + } +} +// ---- +// DeclarationError: (75-81): Identifier already declared. diff --git a/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_activation_050.sol b/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_activation_050.sol new file mode 100644 index 00000000..20ea0349 --- /dev/null +++ b/test/libsolidity/syntaxTests/scoping/double_variable_declaration_disjoint_scope_activation_050.sol @@ -0,0 +1,10 @@ +pragma experimental "v0.5.0"; +contract test { + function f() pure public { + { uint x; } + uint x; + } +} +// ---- +// Warning: (87-93): Unused local variable. +// Warning: (105-111): Unused local variable. diff --git a/test/libsolidity/syntaxTests/scoping/name_shadowing.sol b/test/libsolidity/syntaxTests/scoping/name_shadowing.sol new file mode 100644 index 00000000..67ada4a4 --- /dev/null +++ b/test/libsolidity/syntaxTests/scoping/name_shadowing.sol @@ -0,0 +1,6 @@ +contract test { + uint256 variable; + function f() pure public { uint32 variable; variable = 2; } +} +// ---- +// Warning: (69-84): This declaration shadows an existing declaration. diff --git a/test/libsolidity/syntaxTests/scoping/scoping.sol b/test/libsolidity/syntaxTests/scoping/scoping.sol new file mode 100644 index 00000000..34b055d9 --- /dev/null +++ b/test/libsolidity/syntaxTests/scoping/scoping.sol @@ -0,0 +1,11 @@ +pragma experimental "v0.5.0"; +contract test { + function f() public { + { + uint256 x; + } + x = 2; + } +} +// ---- +// DeclarationError: (123-124): Undeclared identifier. diff --git a/test/libsolidity/syntaxTests/scoping/scoping_activation.sol b/test/libsolidity/syntaxTests/scoping/scoping_activation.sol new file mode 100644 index 00000000..7334bc49 --- /dev/null +++ b/test/libsolidity/syntaxTests/scoping/scoping_activation.sol @@ -0,0 +1,9 @@ +pragma experimental "v0.5.0"; +contract test { + function f() pure public { + x = 3; + uint x; + } +} +// ---- +// DeclarationError: (85-86): Undeclared identifier. Did you mean "x"? diff --git a/test/libsolidity/syntaxTests/scoping/scoping_activation_old.sol b/test/libsolidity/syntaxTests/scoping/scoping_activation_old.sol new file mode 100644 index 00000000..d893a889 --- /dev/null +++ b/test/libsolidity/syntaxTests/scoping/scoping_activation_old.sol @@ -0,0 +1,6 @@ +contract test { + function f() pure public { + x = 3; + uint x; + } +} diff --git a/test/libsolidity/syntaxTests/scoping/scoping_for.sol b/test/libsolidity/syntaxTests/scoping/scoping_for.sol new file mode 100644 index 00000000..6e5b7095 --- /dev/null +++ b/test/libsolidity/syntaxTests/scoping/scoping_for.sol @@ -0,0 +1,8 @@ +pragma experimental "v0.5.0"; +contract test { + function f() pure public { + for (uint x = 0; x < 10; x ++){ + x = 2; + } + } +} diff --git a/test/libsolidity/syntaxTests/scoping/scoping_for2.sol b/test/libsolidity/syntaxTests/scoping/scoping_for2.sol new file mode 100644 index 00000000..eb74b8ab --- /dev/null +++ b/test/libsolidity/syntaxTests/scoping/scoping_for2.sol @@ -0,0 +1,7 @@ +pragma experimental "v0.5.0"; +contract test { + function f() pure public { + for (uint x = 0; x < 10; x ++) + x = 2; + } +} diff --git a/test/libsolidity/syntaxTests/scoping/scoping_for3.sol b/test/libsolidity/syntaxTests/scoping/scoping_for3.sol new file mode 100644 index 00000000..1814cb47 --- /dev/null +++ b/test/libsolidity/syntaxTests/scoping/scoping_for3.sol @@ -0,0 +1,11 @@ +pragma experimental "v0.5.0"; +contract test { + function f() pure public { + for (uint x = 0; x < 10; x ++){ + x = 2; + } + x = 4; + } +} +// ---- +// DeclarationError: (154-155): Undeclared identifier. diff --git a/test/libsolidity/syntaxTests/scoping/scoping_for_decl_in_body.sol b/test/libsolidity/syntaxTests/scoping/scoping_for_decl_in_body.sol new file mode 100644 index 00000000..3e80b385 --- /dev/null +++ b/test/libsolidity/syntaxTests/scoping/scoping_for_decl_in_body.sol @@ -0,0 +1,10 @@ +pragma experimental "v0.5.0"; +contract test { + function f() pure public { + for (;; y++){ + uint y = 3; + } + } +} +// ---- +// DeclarationError: (93-94): Undeclared identifier. diff --git a/test/libsolidity/syntaxTests/scoping/scoping_old.sol b/test/libsolidity/syntaxTests/scoping/scoping_old.sol new file mode 100644 index 00000000..83f6b60b --- /dev/null +++ b/test/libsolidity/syntaxTests/scoping/scoping_old.sol @@ -0,0 +1,6 @@ +contract test { + function f() pure public { + x = 4; + uint256 x = 2; + } +} diff --git a/test/libsolidity/syntaxTests/scoping/scoping_self_use.sol b/test/libsolidity/syntaxTests/scoping/scoping_self_use.sol new file mode 100644 index 00000000..9e2c0171 --- /dev/null +++ b/test/libsolidity/syntaxTests/scoping/scoping_self_use.sol @@ -0,0 +1,5 @@ +contract test { + function f() pure public { + uint a = a; + } +} diff --git a/test/libsolidity/syntaxTests/scoping/scoping_self_use_050.sol b/test/libsolidity/syntaxTests/scoping/scoping_self_use_050.sol new file mode 100644 index 00000000..ab3dcefb --- /dev/null +++ b/test/libsolidity/syntaxTests/scoping/scoping_self_use_050.sol @@ -0,0 +1,8 @@ +pragma experimental "v0.5.0"; +contract test { + function f() pure public { + uint a = a; + } +} +// ---- +// DeclarationError: (94-95): Undeclared identifier. Did you mean "a"? diff --git a/test/libsolidity/syntaxTests/signed_rational_modulus.sol b/test/libsolidity/syntaxTests/signed_rational_modulus.sol new file mode 100644 index 00000000..b37d33d0 --- /dev/null +++ b/test/libsolidity/syntaxTests/signed_rational_modulus.sol @@ -0,0 +1,8 @@ +contract test { + function f() public pure { + fixed a = 0.42578125 % -0.4271087646484375; + fixed b = .5 % a; + fixed c = a % b; + a; b; c; + } +} diff --git a/test/libsolidity/syntaxTests/smoke_test.sol b/test/libsolidity/syntaxTests/smoke_test.sol new file mode 100644 index 00000000..6abaff18 --- /dev/null +++ b/test/libsolidity/syntaxTests/smoke_test.sol @@ -0,0 +1,6 @@ +contract test { + uint256 stateVariable1; + function fun(uint256 arg1) public { uint256 y; y = arg1; } +} +// ---- +// Warning: (42-100): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/specialFunctions/abi_encode_structs.sol b/test/libsolidity/syntaxTests/specialFunctions/abi_encode_structs.sol new file mode 100644 index 00000000..d9eebee4 --- /dev/null +++ b/test/libsolidity/syntaxTests/specialFunctions/abi_encode_structs.sol @@ -0,0 +1,17 @@ +contract C { + struct S { uint x; } + S s; + struct T { uint y; } + T t; + function f() public view { + abi.encode(s, t); + } + function g() public view { + abi.encodePacked(s, t); + } +} +// ---- +// TypeError: (131-132): This type cannot be encoded. +// TypeError: (134-135): This type cannot be encoded. +// TypeError: (200-201): This type cannot be encoded. +// TypeError: (203-204): This type cannot be encoded. diff --git a/test/libsolidity/syntaxTests/specialFunctions/abi_encode_structs_abiv2.sol b/test/libsolidity/syntaxTests/specialFunctions/abi_encode_structs_abiv2.sol new file mode 100644 index 00000000..d6cf60e4 --- /dev/null +++ b/test/libsolidity/syntaxTests/specialFunctions/abi_encode_structs_abiv2.sol @@ -0,0 +1,18 @@ +pragma experimental ABIEncoderV2; + +contract C { + struct S { uint x; } + S s; + struct T { uint y; } + T t; + function f() public view { + abi.encode(s, t); + } + function g() public view { + abi.encodePacked(s, t); + } +} +// ---- +// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments. +// TypeError: (235-236): This type cannot be encoded. +// TypeError: (238-239): This type cannot be encoded. diff --git a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_internal_functions.sol b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_internal_functions.sol new file mode 100644 index 00000000..c98d7a57 --- /dev/null +++ b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_internal_functions.sol @@ -0,0 +1,11 @@ +contract C { + function f() public pure { + bytes32 h = keccak256(keccak256, f, this.f.gas, block.blockhash); + h; + } +} +// ---- +// TypeError: (74-83): This type cannot be encoded. +// TypeError: (85-86): This type cannot be encoded. +// TypeError: (88-98): This type cannot be encoded. +// TypeError: (100-115): This type cannot be encoded. diff --git a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_special_types.sol b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_special_types.sol new file mode 100644 index 00000000..f1b5606e --- /dev/null +++ b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_special_types.sol @@ -0,0 +1,13 @@ +contract C { + function f() public pure { + bool a = address(this).call(address(this).delegatecall, super); + bool b = address(this).delegatecall(log0, tx, mulmod); + a; b; + } +} +// ---- +// TypeError: (80-106): This type cannot be encoded. +// TypeError: (108-113): This type cannot be encoded. +// TypeError: (160-164): This type cannot be encoded. +// TypeError: (166-168): This type cannot be encoded. +// TypeError: (170-176): This type cannot be encoded. diff --git a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs.sol b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs.sol new file mode 100644 index 00000000..fa910260 --- /dev/null +++ b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs.sol @@ -0,0 +1,13 @@ +contract C { + struct S { uint x; } + S s; + struct T { uint y; } + T t; + function f() public view { + bytes32 a = sha256(s, t); + a; + } +} +// ---- +// TypeError: (139-140): This type cannot be encoded. +// TypeError: (142-143): This type cannot be encoded. diff --git a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs_abiv2.sol b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs_abiv2.sol new file mode 100644 index 00000000..1187ce4a --- /dev/null +++ b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs_abiv2.sol @@ -0,0 +1,16 @@ +pragma experimental ABIEncoderV2; + +contract C { + struct S { uint x; } + S s; + struct T { uint y; } + T t; + function f() public view { + bytes32 a = sha256(s, t); + a; + } +} +// ---- +// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments. +// TypeError: (174-175): This type cannot be encoded. +// TypeError: (177-178): This type cannot be encoded. diff --git a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_types.sol b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_types.sol new file mode 100644 index 00000000..d10c1718 --- /dev/null +++ b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_types.sol @@ -0,0 +1,17 @@ +contract C { + struct S { uint x; } + S s; + struct T { } + T t; + enum A { X, Y } + function f() public pure { + bool a = address(this).delegatecall(S, A, A.X, T, uint, uint[]); + } +} +// ---- +// Warning: (51-63): Defining empty structs is deprecated. +// TypeError: (168-169): This type cannot be encoded. +// TypeError: (171-172): This type cannot be encoded. +// TypeError: (179-180): This type cannot be encoded. +// TypeError: (182-186): This type cannot be encoded. +// TypeError: (188-194): This type cannot be encoded. diff --git a/test/libsolidity/syntaxTests/specialFunctions/types_without_encoding_problems.sol b/test/libsolidity/syntaxTests/specialFunctions/types_without_encoding_problems.sol new file mode 100644 index 00000000..c8364548 --- /dev/null +++ b/test/libsolidity/syntaxTests/specialFunctions/types_without_encoding_problems.sol @@ -0,0 +1,9 @@ +contract C { + uint[3] sarr; + function f() view public { + uint[3] memory arr; + bytes32 h = keccak256(this.f, arr, sarr); + h; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/structs/recursion/multi_struct_composition.sol b/test/libsolidity/syntaxTests/structs/recursion/multi_struct_composition.sol new file mode 100644 index 00000000..895bb6c5 --- /dev/null +++ b/test/libsolidity/syntaxTests/structs/recursion/multi_struct_composition.sol @@ -0,0 +1,15 @@ +pragma experimental ABIEncoderV2; + +contract C { + struct T { U u; V v; } + + struct U { W w; } + + struct V { W w; } + + struct W { uint x; } + + function f(T) public pure { } +} +// ---- +// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments. diff --git a/test/libsolidity/syntaxTests/structs/recursion/parallel_structs.sol b/test/libsolidity/syntaxTests/structs/recursion/parallel_structs.sol new file mode 100644 index 00000000..96362ef0 --- /dev/null +++ b/test/libsolidity/syntaxTests/structs/recursion/parallel_structs.sol @@ -0,0 +1,15 @@ +pragma experimental ABIEncoderV2; + +contract TestContract +{ + struct SubStruct { + uint256 id; + } + struct TestStruct { + SubStruct subStruct1; + SubStruct subStruct2; + } + function addTestStruct(TestStruct) public pure {} +} +// ---- +// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments. diff --git a/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs.sol b/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs.sol new file mode 100644 index 00000000..4966a731 --- /dev/null +++ b/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs.sol @@ -0,0 +1,7 @@ +contract C { + struct S { uint a; S[] sub; } + function f() public pure returns (uint, S) { + } +} +// ---- +// TypeError: (91-92): Internal or recursive type is not allowed for public or external functions. diff --git a/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs2.sol b/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs2.sol new file mode 100644 index 00000000..68113924 --- /dev/null +++ b/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs2.sol @@ -0,0 +1,7 @@ +contract C { + struct S { uint a; S[2][] sub; } + function f() public pure returns (uint, S) { + } +} +// ---- +// TypeError: (94-95): Internal or recursive type is not allowed for public or external functions. diff --git a/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs3.sol b/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs3.sol new file mode 100644 index 00000000..47690d9b --- /dev/null +++ b/test/libsolidity/syntaxTests/structs/recursion/return_recursive_structs3.sol @@ -0,0 +1,8 @@ +contract C { + struct S { uint a; S[][][] sub; } + struct T { S s; } + function f() public pure returns (uint x, T t) { + } +} +// ---- +// TypeError: (119-122): Internal or recursive type is not allowed for public or external functions. diff --git a/test/libsolidity/syntaxTests/structs/recursion/struct_definition_directly_recursive.sol b/test/libsolidity/syntaxTests/structs/recursion/struct_definition_directly_recursive.sol new file mode 100644 index 00000000..bcffe383 --- /dev/null +++ b/test/libsolidity/syntaxTests/structs/recursion/struct_definition_directly_recursive.sol @@ -0,0 +1,8 @@ +contract Test { + struct MyStructName { + address addr; + MyStructName x; + } +} +// ---- +// TypeError: (20-93): Recursive struct definition. diff --git a/test/libsolidity/syntaxTests/structs/recursion/struct_definition_indirectly_recursive.sol b/test/libsolidity/syntaxTests/structs/recursion/struct_definition_indirectly_recursive.sol new file mode 100644 index 00000000..64dab8d0 --- /dev/null +++ b/test/libsolidity/syntaxTests/structs/recursion/struct_definition_indirectly_recursive.sol @@ -0,0 +1,12 @@ +contract Test { + struct MyStructName1 { + address addr; + uint256 count; + MyStructName2 x; + } + struct MyStructName2 { + MyStructName1 x; + } +} +// ---- +// TypeError: (20-118): Recursive struct definition. diff --git a/test/libsolidity/syntaxTests/structs/recursion/struct_definition_not_really_recursive.sol b/test/libsolidity/syntaxTests/structs/recursion/struct_definition_not_really_recursive.sol new file mode 100644 index 00000000..6ec4ee01 --- /dev/null +++ b/test/libsolidity/syntaxTests/structs/recursion/struct_definition_not_really_recursive.sol @@ -0,0 +1,4 @@ +contract Test { + struct S1 { uint a; } + struct S2 { S1 x; S1 y; } +} diff --git a/test/libsolidity/syntaxTests/structs/recursion/struct_definition_recursion_via_mapping.sol b/test/libsolidity/syntaxTests/structs/recursion/struct_definition_recursion_via_mapping.sol new file mode 100644 index 00000000..926981b3 --- /dev/null +++ b/test/libsolidity/syntaxTests/structs/recursion/struct_definition_recursion_via_mapping.sol @@ -0,0 +1,7 @@ +contract Test { + struct MyStructName1 { + address addr; + uint256 count; + mapping(uint => MyStructName1) x; + } +} diff --git a/test/libsolidity/syntaxTests/tight_packing_literals.sol b/test/libsolidity/syntaxTests/tight_packing_literals.sol new file mode 100644 index 00000000..8258a8a6 --- /dev/null +++ b/test/libsolidity/syntaxTests/tight_packing_literals.sol @@ -0,0 +1,25 @@ +contract C { + function f() pure public returns (bytes32) { + return keccak256(1); + } + function g() pure public returns (bytes32) { + return sha3(1); + } + function h() pure public returns (bytes32) { + return sha256(1); + } + function j() pure public returns (bytes32) { + return ripemd160(1); + } + function k() pure public returns (bytes) { + return abi.encodePacked(1); + } +} + +// ---- +// Warning: (87-88): The type of "int_const 1" was inferred as uint8. This is probably not desired. Use an explicit type to silence this warning. +// Warning: (161-168): "sha3" has been deprecated in favour of "keccak256" +// Warning: (166-167): The type of "int_const 1" was inferred as uint8. This is probably not desired. Use an explicit type to silence this warning. +// Warning: (247-248): The type of "int_const 1" was inferred as uint8. This is probably not desired. Use an explicit type to silence this warning. +// Warning: (331-332): The type of "int_const 1" was inferred as uint8. This is probably not desired. Use an explicit type to silence this warning. +// Warning: (420-421): The type of "int_const 1" was inferred as uint8. This is probably not desired. Use an explicit type to silence this warning. diff --git a/test/libsolidity/syntaxTests/tight_packing_literals_fine.sol b/test/libsolidity/syntaxTests/tight_packing_literals_fine.sol new file mode 100644 index 00000000..46407f71 --- /dev/null +++ b/test/libsolidity/syntaxTests/tight_packing_literals_fine.sol @@ -0,0 +1,11 @@ +contract C { + function f() pure public returns (bytes32) { + return keccak256(uint8(1)); + } + function g() pure public returns (bytes) { + return abi.encode(1); + } + function h() pure public returns (bytes) { + return abi.encodePacked(uint8(1)); + } +} diff --git a/test/libsolidity/syntaxTests/types/rational_number_array_index_limit.sol b/test/libsolidity/syntaxTests/types/rational_number_array_index_limit.sol new file mode 100644 index 00000000..45ede998 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/rational_number_array_index_limit.sol @@ -0,0 +1,5 @@ +contract c { + uint[2**253] data; +} +// ---- +// Warning: (17-34): Variable covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction. diff --git a/test/libsolidity/syntaxTests/types/rational_number_bitshift_limit.sol b/test/libsolidity/syntaxTests/types/rational_number_bitshift_limit.sol new file mode 100644 index 00000000..94981aa0 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/rational_number_bitshift_limit.sol @@ -0,0 +1,13 @@ +contract c { + function f() public pure { + int a; + a = 1 << 4095; // shift is fine, but result too large + a = 1 << 4096; // too large + a = (1E1233) << 2; // too large + } +} +// ---- +// TypeError: (71-80): Type int_const 5221...(1225 digits omitted)...5168 is not implicitly convertible to expected type int256. +// TypeError: (133-142): Operator << not compatible with types int_const 1 and int_const 4096 +// TypeError: (169-182): Operator << not compatible with types int_const 1000...(1226 digits omitted)...0000 and int_const 2 +// TypeError: (169-182): Type int_const 1000...(1226 digits omitted)...0000 is not implicitly convertible to expected type int256. diff --git a/test/libsolidity/syntaxTests/types/rational_number_div_limit.sol b/test/libsolidity/syntaxTests/types/rational_number_div_limit.sol new file mode 100644 index 00000000..1b0b5f94 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/rational_number_div_limit.sol @@ -0,0 +1,9 @@ +contract c { + function f() public pure { + int a; + a = 1/(2<<4094)/(2<<4094); + } +} +// ---- +// TypeError: (71-92): Operator / not compatible with types rational_const 1 / 5221...(1225 digits omitted)...5168 and int_const 5221...(1225 digits omitted)...5168 +// TypeError: (71-92): Type rational_const 1 / 5221...(1225 digits omitted)...5168 is not implicitly convertible to expected type int256. Try converting to type ufixed8x80 or use an explicit conversion. diff --git a/test/libsolidity/syntaxTests/types/rational_number_exp_limit.sol b/test/libsolidity/syntaxTests/types/rational_number_exp_limit.sol new file mode 100644 index 00000000..6785f580 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/rational_number_exp_limit.sol @@ -0,0 +1,50 @@ +contract c { + function f() public pure { + int a; + a = 4 ** 4 ** 2 ** 4 ** 4 ** 4 ** 4; + a = -4 ** 4 ** 2 ** 4 ** 4 ** 4 ** 4 ** 4; + a = 4 ** (-(2 ** 4 ** 4 ** 4 ** 4 ** 4)); + a = 0 ** 1E1233; // fine + a = 1 ** 1E1233; // fine + a = -1 ** 1E1233; // fine + a = 2 ** 1E1233; + a = -2 ** 1E1233; + a = 2 ** -1E1233; + a = -2 ** -1E1233; + a = 1E1233 ** 2; + a = -1E1233 ** 2; + a = 1E1233 ** -2; + a = -1E1233 ** -2; + a = 1E1233 ** 1E1233; + a = 1E1233 ** -1E1233; + a = -1E1233 ** 1E1233; + a = -1E1233 ** -1E1233; + } +} +// ---- +// TypeError: (71-102): Operator ** not compatible with types int_const 1797...(301 digits omitted)...7216 and int_const 4 +// TypeError: (71-102): Type int_const 1797...(301 digits omitted)...7216 is not implicitly convertible to expected type int256. +// TypeError: (116-148): Operator ** not compatible with types int_const 1797...(301 digits omitted)...7216 and int_const 4 +// TypeError: (116-153): Operator ** not compatible with types int_const 1797...(301 digits omitted)...7216 and int_const 4 +// TypeError: (116-153): Type int_const 1797...(301 digits omitted)...7216 is not implicitly convertible to expected type int256. +// TypeError: (167-203): Operator ** not compatible with types int_const 4 and int_const -179...(302 digits omitted)...7216 +// TypeError: (317-328): Operator ** not compatible with types int_const 2 and int_const 1000...(1226 digits omitted)...0000 +// TypeError: (342-354): Operator ** not compatible with types int_const -2 and int_const 1000...(1226 digits omitted)...0000 +// TypeError: (368-380): Operator ** not compatible with types int_const 2 and int_const -100...(1227 digits omitted)...0000 +// TypeError: (394-407): Operator ** not compatible with types int_const -2 and int_const -100...(1227 digits omitted)...0000 +// TypeError: (421-432): Operator ** not compatible with types int_const 1000...(1226 digits omitted)...0000 and int_const 2 +// TypeError: (421-432): Type int_const 1000...(1226 digits omitted)...0000 is not implicitly convertible to expected type int256. +// TypeError: (446-458): Operator ** not compatible with types int_const -100...(1227 digits omitted)...0000 and int_const 2 +// TypeError: (446-458): Type int_const -100...(1227 digits omitted)...0000 is not implicitly convertible to expected type int256. +// TypeError: (472-484): Operator ** not compatible with types int_const 1000...(1226 digits omitted)...0000 and int_const -2 +// TypeError: (472-484): Type int_const 1000...(1226 digits omitted)...0000 is not implicitly convertible to expected type int256. +// TypeError: (498-511): Operator ** not compatible with types int_const -100...(1227 digits omitted)...0000 and int_const -2 +// TypeError: (498-511): Type int_const -100...(1227 digits omitted)...0000 is not implicitly convertible to expected type int256. +// TypeError: (525-541): Operator ** not compatible with types int_const 1000...(1226 digits omitted)...0000 and int_const 1000...(1226 digits omitted)...0000 +// TypeError: (525-541): Type int_const 1000...(1226 digits omitted)...0000 is not implicitly convertible to expected type int256. +// TypeError: (555-572): Operator ** not compatible with types int_const 1000...(1226 digits omitted)...0000 and int_const -100...(1227 digits omitted)...0000 +// TypeError: (555-572): Type int_const 1000...(1226 digits omitted)...0000 is not implicitly convertible to expected type int256. +// TypeError: (586-603): Operator ** not compatible with types int_const -100...(1227 digits omitted)...0000 and int_const 1000...(1226 digits omitted)...0000 +// TypeError: (586-603): Type int_const -100...(1227 digits omitted)...0000 is not implicitly convertible to expected type int256. +// TypeError: (617-635): Operator ** not compatible with types int_const -100...(1227 digits omitted)...0000 and int_const -100...(1227 digits omitted)...0000 +// TypeError: (617-635): Type int_const -100...(1227 digits omitted)...0000 is not implicitly convertible to expected type int256. diff --git a/test/libsolidity/syntaxTests/types/rational_number_literal_limit_1.sol b/test/libsolidity/syntaxTests/types/rational_number_literal_limit_1.sol new file mode 100644 index 00000000..233857a3 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/rational_number_literal_limit_1.sol @@ -0,0 +1,9 @@ +contract c { + function bignum() public { + uint256 a; + a = 1e1233 / 1e1233; // 1e1233 is still fine + a = 1e1234; // 1e1234 is too big + } +} +// ---- +// TypeError: (128-134): Invalid literal value. diff --git a/test/libsolidity/syntaxTests/types/rational_number_literal_limit_2.sol b/test/libsolidity/syntaxTests/types/rational_number_literal_limit_2.sol new file mode 100644 index 00000000..16673924 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/rational_number_literal_limit_2.sol @@ -0,0 +1,9 @@ +contract c { + function bignum() public { + uint a; + a = 134562324532464234452335168163516E1200 / 134562324532464234452335168163516E1200; // still fine + a = 1345623245324642344523351681635168E1200; // too large + } +} +// ---- +// TypeError: (179-218): Invalid literal value. diff --git a/test/libsolidity/syntaxTests/types/rational_number_literal_limit_3.sol b/test/libsolidity/syntaxTests/types/rational_number_literal_limit_3.sol new file mode 100644 index 00000000..5a696171 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/rational_number_literal_limit_3.sol @@ -0,0 +1,9 @@ +contract c { + function bignum() public { + uint a; + a = 134562324532464.234452335168163517E1200 / 134562324532464.234452335168163517E1200; // still fine + a = 134562324532464.2344523351681635177E1200; // too large + } +} +// ---- +// TypeError: (181-221): Invalid literal value. diff --git a/test/libsolidity/syntaxTests/types/rational_number_mul_limit.sol b/test/libsolidity/syntaxTests/types/rational_number_mul_limit.sol new file mode 100644 index 00000000..bbed94b5 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/rational_number_mul_limit.sol @@ -0,0 +1,9 @@ +contract c { + function f() public pure { + int a; + a = (1<<4095)*(1<<4095); + } +} +// ---- +// TypeError: (71-90): Operator * not compatible with types int_const 5221...(1225 digits omitted)...5168 and int_const 5221...(1225 digits omitted)...5168 +// TypeError: (71-90): Type int_const 5221...(1225 digits omitted)...5168 is not implicitly convertible to expected type int256. diff --git a/test/libsolidity/syntaxTests/viewPure/view_pure_abi_encode.sol b/test/libsolidity/syntaxTests/viewPure/view_pure_abi_encode.sol new file mode 100644 index 00000000..ca7db42e --- /dev/null +++ b/test/libsolidity/syntaxTests/viewPure/view_pure_abi_encode.sol @@ -0,0 +1,8 @@ +contract C { + function f() pure public returns (bytes r) { + r = abi.encode(1, 2); + r = abi.encodePacked(f()); + r = abi.encodeWithSelector(0x12345678, 1); + r = abi.encodeWithSignature("f(uint256)", 4); + } +} diff --git a/test/libsolidity/syntaxTests/viewPure/view_pure_abi_encode_arguments.sol b/test/libsolidity/syntaxTests/viewPure/view_pure_abi_encode_arguments.sol new file mode 100644 index 00000000..547362c3 --- /dev/null +++ b/test/libsolidity/syntaxTests/viewPure/view_pure_abi_encode_arguments.sol @@ -0,0 +1,36 @@ +contract C { + uint x; + function gView() public view returns (uint) { return x; } + function gNonPayable() public returns (uint) { x = 4; return 0; } + + function f1() view public returns (bytes) { + return abi.encode(gView()); + } + function f2() view public returns (bytes) { + return abi.encodePacked(gView()); + } + function f3() view public returns (bytes) { + return abi.encodeWithSelector(0x12345678, gView()); + } + function f4() view public returns (bytes) { + return abi.encodeWithSignature("f(uint256)", gView()); + } + function g1() public returns (bytes) { + return abi.encode(gNonPayable()); + } + function g2() public returns (bytes) { + return abi.encodePacked(gNonPayable()); + } + function g3() public returns (bytes) { + return abi.encodeWithSelector(0x12345678, gNonPayable()); + } + function g4() public returns (bytes) { + return abi.encodeWithSignature("f(uint256)", gNonPayable()); + } + // This will generate the only warning. + function check() public returns (bytes) { + return abi.encode(2); + } +} +// ---- +// Warning: (1044-1121): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/virtualLookup/modifiers_in_libraries.sol b/test/libsolidity/syntaxTests/virtualLookup/modifiers_in_libraries.sol new file mode 100644 index 00000000..b033fd0c --- /dev/null +++ b/test/libsolidity/syntaxTests/virtualLookup/modifiers_in_libraries.sol @@ -0,0 +1,14 @@ +library WithModifier { + modifier mod() { require(msg.value > 10 ether); _; } + function withMod(uint self) mod() internal view { require(self > 0); } +} + +contract Test { + using WithModifier for *; + + function f(uint _value) public payable { + _value.withMod(); + WithModifier.withMod(_value); + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/visibility/external_library_function.sol b/test/libsolidity/syntaxTests/visibility/external_library_function.sol new file mode 100644 index 00000000..110e74db --- /dev/null +++ b/test/libsolidity/syntaxTests/visibility/external_library_function.sol @@ -0,0 +1,14 @@ +library L { + function f(uint) pure external {} +} + +contract C { + using L for *; + + function f() public pure { + L.f(2); + uint x; + x.f(); + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/visibility/interface/function_default.sol b/test/libsolidity/syntaxTests/visibility/interface/function_default.sol new file mode 100644 index 00000000..72ce3b40 --- /dev/null +++ b/test/libsolidity/syntaxTests/visibility/interface/function_default.sol @@ -0,0 +1,6 @@ +interface I { + function f(); +} +// ---- +// Warning: (15-28): Functions in interfaces should be declared external. +// Warning: (15-28): No visibility specified. Defaulting to "public". In interfaces it defaults to external. diff --git a/test/libsolidity/syntaxTests/visibility/interface/function_default050.sol b/test/libsolidity/syntaxTests/visibility/interface/function_default050.sol new file mode 100644 index 00000000..513df26b --- /dev/null +++ b/test/libsolidity/syntaxTests/visibility/interface/function_default050.sol @@ -0,0 +1,7 @@ +pragma experimental "v0.5.0"; +interface I { + function f(); +} +// ---- +// SyntaxError: (45-58): No visibility specified. +// TypeError: (45-58): Functions in interfaces must be declared external. diff --git a/test/libsolidity/syntaxTests/visibility/interface/function_external050.sol b/test/libsolidity/syntaxTests/visibility/interface/function_external050.sol new file mode 100644 index 00000000..3f0a9aca --- /dev/null +++ b/test/libsolidity/syntaxTests/visibility/interface/function_external050.sol @@ -0,0 +1,5 @@ +pragma experimental "v0.5.0"; +interface I { + function f() external; +} +// ---- diff --git a/test/libsolidity/syntaxTests/visibility/interface/function_internal.sol b/test/libsolidity/syntaxTests/visibility/interface/function_internal.sol new file mode 100644 index 00000000..ac62e69b --- /dev/null +++ b/test/libsolidity/syntaxTests/visibility/interface/function_internal.sol @@ -0,0 +1,5 @@ +interface I { + function f() internal; +} +// ---- +// TypeError: (15-37): Functions in interfaces cannot be internal or private. diff --git a/test/libsolidity/syntaxTests/visibility/interface/function_private.sol b/test/libsolidity/syntaxTests/visibility/interface/function_private.sol new file mode 100644 index 00000000..881e647e --- /dev/null +++ b/test/libsolidity/syntaxTests/visibility/interface/function_private.sol @@ -0,0 +1,5 @@ +interface I { + function f() private; +} +// ---- +// TypeError: (15-36): Functions in interfaces cannot be internal or private. diff --git a/test/libsolidity/syntaxTests/visibility/interface/function_public.sol b/test/libsolidity/syntaxTests/visibility/interface/function_public.sol new file mode 100644 index 00000000..891d9fdf --- /dev/null +++ b/test/libsolidity/syntaxTests/visibility/interface/function_public.sol @@ -0,0 +1,5 @@ +interface I { + function f() public; +} +// ---- +// Warning: (15-35): Functions in interfaces should be declared external. diff --git a/test/libsolidity/syntaxTests/visibility/interface/function_public050.sol b/test/libsolidity/syntaxTests/visibility/interface/function_public050.sol new file mode 100644 index 00000000..e0c04095 --- /dev/null +++ b/test/libsolidity/syntaxTests/visibility/interface/function_public050.sol @@ -0,0 +1,6 @@ +pragma experimental "v0.5.0"; +interface I { + function f() public; +} +// ---- +// TypeError: (45-65): Functions in interfaces must be declared external. |