diff options
author | chriseth <chris@ethereum.org> | 2018-06-29 00:08:45 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2018-06-29 06:23:52 +0800 |
commit | eeef82b2d77c6f956039c57b0598e684254ee6dd (patch) | |
tree | 82887915936dbf242d5574c1fe9d61f5ace312d9 /test/libsolidity/syntaxTests | |
parent | 4268062985e434b00f07e3f90772b94538933b9c (diff) | |
download | dexon-solidity-eeef82b2d77c6f956039c57b0598e684254ee6dd.tar.gz dexon-solidity-eeef82b2d77c6f956039c57b0598e684254ee6dd.tar.zst dexon-solidity-eeef82b2d77c6f956039c57b0598e684254ee6dd.zip |
Fallback function has to be external: backwards-compatible changes.
Diffstat (limited to 'test/libsolidity/syntaxTests')
30 files changed, 81 insertions, 64 deletions
diff --git a/test/libsolidity/syntaxTests/fallback/default_visibility.sol b/test/libsolidity/syntaxTests/fallback/default_visibility.sol new file mode 100644 index 00000000..2cb0af90 --- /dev/null +++ b/test/libsolidity/syntaxTests/fallback/default_visibility.sol @@ -0,0 +1,6 @@ +contract C { + // Check that visibility is also enforced for the fallback function. + function() {} +} +// ---- +// Warning: (90-103): No visibility specified. Defaulting to "public". diff --git a/test/libsolidity/syntaxTests/fallback/pure_modifier.sol b/test/libsolidity/syntaxTests/fallback/pure_modifier.sol index 20d5b0ac..12d790d1 100644 --- a/test/libsolidity/syntaxTests/fallback/pure_modifier.sol +++ b/test/libsolidity/syntaxTests/fallback/pure_modifier.sol @@ -1,6 +1,6 @@ contract C { uint x; - function() pure { x = 2; } + function() external pure { x = 2; } } // ---- -// TypeError: (29-55): Fallback function must be payable or non-payable, but is "pure". +// TypeError: (29-64): Fallback function must be payable or non-payable, but is "pure". diff --git a/test/libsolidity/syntaxTests/fallback/view_modifier.sol b/test/libsolidity/syntaxTests/fallback/view_modifier.sol index 44c5d204..2497e9fa 100644 --- a/test/libsolidity/syntaxTests/fallback/view_modifier.sol +++ b/test/libsolidity/syntaxTests/fallback/view_modifier.sol @@ -1,6 +1,6 @@ contract C { uint x; - function() view { x = 2; } + function() external view { x = 2; } } // ---- -// TypeError: (29-55): Fallback function must be payable or non-payable, but is "view". +// TypeError: (29-64): Fallback function must be payable or non-payable, but is "view". diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/074_fallback_function.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/074_fallback_function.sol index 7e64bbe2..466e80cb 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/074_fallback_function.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/074_fallback_function.sol @@ -1,4 +1,4 @@ contract C { uint x; - function() public { x = 2; } + function() external { x = 2; } } diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/075_fallback_function_with_arguments.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/075_fallback_function_with_arguments.sol index 2c1d2a1b..68d40952 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/075_fallback_function_with_arguments.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/075_fallback_function_with_arguments.sol @@ -1,6 +1,6 @@ contract C { uint x; - function(uint a) public { x = 2; } + function(uint a) external { x = 2; } } // ---- // TypeError: (37-45): Fallback function cannot take parameters. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/076_fallback_function_in_library.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/076_fallback_function_in_library.sol index 11fef976..25878a61 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/076_fallback_function_in_library.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/076_fallback_function_in_library.sol @@ -1,5 +1,5 @@ library C { - function() public {} + function() external {} } // ---- -// TypeError: (16-36): Libraries cannot have fallback functions. +// TypeError: (16-38): Libraries cannot have fallback functions. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/077_fallback_function_with_return_parameters.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/077_fallback_function_with_return_parameters.sol index 905bcd2d..3ff7a1c4 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/077_fallback_function_with_return_parameters.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/077_fallback_function_with_return_parameters.sol @@ -1,5 +1,5 @@ contract C { - function() public returns (uint) { } + function() external returns (uint) { } } // ---- -// TypeError: (43-49): Fallback function cannot return values. +// TypeError: (45-51): Fallback function cannot return values. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/078_fallback_function_twice.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/078_fallback_function_twice.sol index 8d839da0..e5746c63 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/078_fallback_function_twice.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/078_fallback_function_twice.sol @@ -1,7 +1,7 @@ contract C { uint x; - function() public { x = 2; } - function() public { x = 3; } + function() external { x = 2; } + function() external { x = 3; } } // ---- -// DeclarationError: (62-90): Only one fallback function is allowed. +// DeclarationError: (64-94): Only one fallback function is allowed. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/079_fallback_function_inheritance.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/079_fallback_function_inheritance.sol index a35a8093..c8c06c6e 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/079_fallback_function_inheritance.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/079_fallback_function_inheritance.sol @@ -1,7 +1,7 @@ contract A { uint x; - function() public { x = 1; } + function() external { x = 1; } } contract C is A { - function() public { x = 2; } + function() external { x = 2; } } diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/196_integer_boolean_or.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/196_integer_boolean_or.sol index 1b522c00..db42786d 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/196_integer_boolean_or.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/196_integer_boolean_or.sol @@ -1,3 +1,3 @@ -contract test { function() public { uint x = 1; uint y = 2; x || y; } } +contract test { function() external { uint x = 1; uint y = 2; x || y; } } // ---- -// TypeError: (60-66): Operator || not compatible with types uint256 and uint256 +// TypeError: (62-68): Operator || not compatible with types uint256 and uint256 diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/197_integer_boolean_and.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/197_integer_boolean_and.sol index cbc3732f..94d1c691 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/197_integer_boolean_and.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/197_integer_boolean_and.sol @@ -1,3 +1,3 @@ -contract test { function() public { uint x = 1; uint y = 2; x && y; } } +contract test { function() external { uint x = 1; uint y = 2; x && y; } } // ---- -// TypeError: (60-66): Operator && not compatible with types uint256 and uint256 +// TypeError: (62-68): Operator && not compatible with types uint256 and uint256 diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/198_integer_boolean_not.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/198_integer_boolean_not.sol index 1d36b0b3..68fe6e94 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/198_integer_boolean_not.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/198_integer_boolean_not.sol @@ -1,3 +1,3 @@ -contract test { function() public { uint x = 1; !x; } } +contract test { function() external { uint x = 1; !x; } } // ---- -// TypeError: (48-50): Unary operator ! cannot be applied to type uint256 +// TypeError: (50-52): Unary operator ! cannot be applied to type uint256 diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/199_integer_unsigned_exp_signed.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/199_integer_unsigned_exp_signed.sol index 5b8b2d3f..fbeadfb6 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/199_integer_unsigned_exp_signed.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/199_integer_unsigned_exp_signed.sol @@ -1,3 +1,3 @@ -contract test { function() public { uint x = 3; int y = -4; x ** y; } } +contract test { function() external { uint x = 3; int y = -4; x ** y; } } // ---- -// TypeError: (60-66): Operator ** not compatible with types uint256 and int256 +// TypeError: (62-68): Operator ** not compatible with types uint256 and int256 diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/200_integer_signed_exp_unsigned.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/200_integer_signed_exp_unsigned.sol index 95c19d17..75e92085 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/200_integer_signed_exp_unsigned.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/200_integer_signed_exp_unsigned.sol @@ -1,3 +1,3 @@ -contract test { function() public { uint x = 3; int y = -4; y ** x; } } +contract test { function() external { uint x = 3; int y = -4; y ** x; } } // ---- -// TypeError: (60-66): Operator ** not compatible with types int256 and uint256 +// TypeError: (62-68): Operator ** not compatible with types int256 and uint256 diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/201_integer_signed_exp_signed.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/201_integer_signed_exp_signed.sol index 394dec88..93e5f065 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/201_integer_signed_exp_signed.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/201_integer_signed_exp_signed.sol @@ -1,3 +1,3 @@ -contract test { function() public { int x = -3; int y = -4; x ** y; } } +contract test { function() external { int x = -3; int y = -4; x ** y; } } // ---- -// TypeError: (60-66): Operator ** not compatible with types int256 and int256 +// TypeError: (62-68): Operator ** not compatible with types int256 and int256 diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/202_bytes_reference_compare_operators.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/202_bytes_reference_compare_operators.sol index d4c513dd..711b794c 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/202_bytes_reference_compare_operators.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/202_bytes_reference_compare_operators.sol @@ -1,3 +1,3 @@ -contract test { bytes a; bytes b; function() public { a == b; } } +contract test { bytes a; bytes b; function() external { a == b; } } // ---- -// TypeError: (54-60): Operator == not compatible with types bytes storage ref and bytes storage ref +// TypeError: (56-62): Operator == not compatible with types bytes storage ref and bytes storage ref diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/203_struct_reference_compare_operators.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/203_struct_reference_compare_operators.sol index de96b798..a74850b3 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/203_struct_reference_compare_operators.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/203_struct_reference_compare_operators.sol @@ -1,3 +1,10 @@ -contract test { struct s {uint a;} s x; s y; function() public { x == y; } } +contract test { + struct s {uint a;} + s x; + s y; + function() external { + x == y; + } +} // ---- -// TypeError: (65-71): Operator == not compatible with types struct test.s storage ref and struct test.s storage ref +// TypeError: (79-85): Operator == not compatible with types struct test.s storage ref and struct test.s storage ref diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/415_interface_functions.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/415_interface_functions.sol index 1f227b54..a5d6561e 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/415_interface_functions.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/415_interface_functions.sol @@ -1,9 +1,5 @@ interface I { - function(); - function f(); + function() external; + function f() external; } // ---- -// Warning: (18-29): Functions in interfaces should be declared external. -// Warning: (34-47): Functions in interfaces should be declared external. -// Warning: (18-29): No visibility specified. Defaulting to "public". In interfaces it defaults to external. -// Warning: (34-47): No visibility specified. Defaulting to "public". In interfaces it defaults to external. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/424_using_interface_complex.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/424_using_interface_complex.sol index a73c29bf..a3dca996 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/424_using_interface_complex.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/424_using_interface_complex.sol @@ -1,17 +1,11 @@ interface I { event A(); - function f(); - function g(); - function(); + function f() external; + function g() external; + function() external; } contract C is I { function f() public { } } // ---- -// Warning: (33-46): Functions in interfaces should be declared external. -// Warning: (51-64): Functions in interfaces should be declared external. -// Warning: (69-80): Functions in interfaces should be declared external. -// Warning: (33-46): No visibility specified. Defaulting to "public". In interfaces it defaults to external. -// Warning: (51-64): No visibility specified. Defaulting to "public". In interfaces it defaults to external. -// Warning: (69-80): No visibility specified. Defaulting to "public". In interfaces it defaults to external. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/463_error_transfer_non_payable_fallback.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/463_error_transfer_non_payable_fallback.sol index 3f6b0283..2b2ef39e 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/463_error_transfer_non_payable_fallback.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/463_error_transfer_non_payable_fallback.sol @@ -2,16 +2,16 @@ // because A's fallback function is not payable. contract A { - function() public {} + function() external {} } contract B { A a; - function() public { + function() external { a.transfer(100); } } // ---- -// Warning: (209-219): Using contract member "transfer" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).transfer" instead. -// TypeError: (209-219): Value transfer to a contract without a payable fallback function. +// Warning: (213-223): Using contract member "transfer" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).transfer" instead. +// TypeError: (213-223): Value transfer to a contract without a payable fallback function. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/464_error_transfer_no_fallback.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/464_error_transfer_no_fallback.sol index afa86040..67398de7 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/464_error_transfer_no_fallback.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/464_error_transfer_no_fallback.sol @@ -6,10 +6,10 @@ contract A {} contract B { A a; - function() public { + function() external { a.transfer(100); } } // ---- -// Warning: (190-200): Using contract member "transfer" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).transfer" instead. -// TypeError: (190-200): Value transfer to a contract without a payable fallback function. +// Warning: (192-202): Using contract member "transfer" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).transfer" instead. +// TypeError: (192-202): Value transfer to a contract without a payable fallback function. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/465_error_send_non_payable_fallback.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/465_error_send_non_payable_fallback.sol index 36f7470b..1a4b2e81 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/465_error_send_non_payable_fallback.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/465_error_send_non_payable_fallback.sol @@ -2,16 +2,16 @@ // because A does not have a payable fallback function. contract A { - function() public {} + function() external {} } contract B { A a; - function() public { + function() external { require(a.send(100)); } } // ---- -// Warning: (220-226): Using contract member "send" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).send" instead. -// TypeError: (220-226): Value transfer to a contract without a payable fallback function. +// Warning: (224-230): Using contract member "send" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).send" instead. +// TypeError: (224-230): Value transfer to a contract without a payable fallback function. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/466_does_not_error_transfer_payable_fallback.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/466_does_not_error_transfer_payable_fallback.sol index 1fa567eb..2b7f8dae 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/466_does_not_error_transfer_payable_fallback.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/466_does_not_error_transfer_payable_fallback.sol @@ -2,15 +2,15 @@ // because A does not have a payable fallback function. contract A { - function() payable public {} + function() payable external {} } contract B { A a; - function() public { + function() external { a.transfer(100); } } // ---- -// Warning: (224-234): Using contract member "transfer" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).transfer" instead. +// Warning: (228-238): Using contract member "transfer" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).transfer" instead. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/467_does_not_error_transfer_regular_function.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/467_does_not_error_transfer_regular_function.sol index bf027e22..65b4a236 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/467_does_not_error_transfer_regular_function.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/467_does_not_error_transfer_regular_function.sol @@ -5,7 +5,7 @@ contract A { contract B { A a; - function() public { + function() external { a.transfer(); } } diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/526_fallback_marked_external.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/526_fallback_marked_external.sol new file mode 100644 index 00000000..6ac551e1 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/526_fallback_marked_external.sol @@ -0,0 +1,3 @@ +contract C { + function () external { } +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/527_fallback_marked_internal.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/527_fallback_marked_internal.sol new file mode 100644 index 00000000..2d425037 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/527_fallback_marked_internal.sol @@ -0,0 +1,4 @@ +contract C { + function () internal { } +} +// ---- diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/528_fallback_marked_private.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/528_fallback_marked_private.sol new file mode 100644 index 00000000..2105c815 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/528_fallback_marked_private.sol @@ -0,0 +1,4 @@ +contract C { + function () private { } +} +// ---- diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/529_fallback_marked_public.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/529_fallback_marked_public.sol new file mode 100644 index 00000000..42585137 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/529_fallback_marked_public.sol @@ -0,0 +1,4 @@ +contract C { + function () public { } +} +// ---- diff --git a/test/libsolidity/syntaxTests/parsing/fallback_function.sol b/test/libsolidity/syntaxTests/parsing/fallback_function.sol index de32b030..054f57de 100644 --- a/test/libsolidity/syntaxTests/parsing/fallback_function.sol +++ b/test/libsolidity/syntaxTests/parsing/fallback_function.sol @@ -1,5 +1,4 @@ contract c { - function() { } + function() external { } } // ---- -// Warning: (17-31): No visibility specified. Defaulting to "public". diff --git a/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions.sol b/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions.sol index e4be73c6..51e36a58 100644 --- a/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions.sol +++ b/test/libsolidity/syntaxTests/viewPureChecker/builtin_functions.sol @@ -14,5 +14,5 @@ contract C { assert(true); x; y; z; } - function() payable public {} + function() payable external {} } |