mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Equality operator allowed for external function types
This commit is contained in:
+12
@@ -0,0 +1,12 @@
|
||||
contract C {
|
||||
function external_test_function() external {}
|
||||
function comparison_operator_for_external_function_with_extra_slots() external returns (bool) {
|
||||
return (
|
||||
(this.external_test_function{gas: 4} == this.external_test_function) &&
|
||||
(this.external_test_function{gas: 4} == this.external_test_function{gas: 4})
|
||||
);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 2271: (193-259): Operator == not compatible with types function () external and function () external
|
||||
// TypeError 2271: (277-351): Operator == not compatible with types function () external and function () external
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
contract C {
|
||||
function external_test_function() external {}
|
||||
function internal_test_function() internal {}
|
||||
|
||||
function comparison_operator_between_internal_and_external_function_pointers() external returns (bool) {
|
||||
function () external external_function_pointer_local = this.external_test_function;
|
||||
function () internal internal_function_pointer_local = internal_test_function;
|
||||
|
||||
assert(
|
||||
this.external_test_function == external_function_pointer_local &&
|
||||
internal_function_pointer_local == internal_test_function
|
||||
);
|
||||
assert(
|
||||
internal_function_pointer_local != external_function_pointer_local &&
|
||||
internal_test_function != this.external_test_function
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 2271: (606-672): Operator != not compatible with types function () and function () external
|
||||
// TypeError 2271: (688-741): Operator != not compatible with types function () and function () external
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
contract C {
|
||||
function external_test_function1(uint num) external {}
|
||||
function external_test_function2(bool val) external {}
|
||||
|
||||
function comparison_operator_between_internal_and_external_function_pointers() external returns (bool) {
|
||||
function () external external_function_pointer_local1 = this.external_test_function1;
|
||||
function () external external_function_pointer_local2 = this.external_test_function2;
|
||||
|
||||
assert(
|
||||
this.external_test_function1 == external_function_pointer_local1 &&
|
||||
this.external_test_function2 == external_function_pointer_local2
|
||||
);
|
||||
assert(
|
||||
external_function_pointer_local2 != external_function_pointer_local1 &&
|
||||
this.external_test_function2 != this.external_test_function1
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 9574: (249-333): Type function (uint256) external is not implicitly convertible to expected type function () external.
|
||||
// TypeError 9574: (343-427): Type function (bool) external is not implicitly convertible to expected type function () external.
|
||||
// TypeError 2271: (458-522): Operator == not compatible with types function (uint256) external and function () external
|
||||
// TypeError 2271: (538-602): Operator == not compatible with types function (bool) external and function () external
|
||||
// TypeError 2271: (726-786): Operator != not compatible with types function (bool) external and function (uint256) external
|
||||
Reference in New Issue
Block a user