mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #4500 from ethereum/v050-interface-functions-must-be-external
[BREAKING] interface functions must be external
This commit is contained in:
@@ -11649,7 +11649,7 @@ BOOST_AUTO_TEST_CASE(interface_contract)
|
||||
char const* sourceCode = R"(
|
||||
interface I {
|
||||
event A();
|
||||
function f() public returns (bool);
|
||||
function f() external returns (bool);
|
||||
function() external payable;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,6 @@ interface I {
|
||||
constructor() public;
|
||||
}
|
||||
// ----
|
||||
// Warning: (15-36): Functions in interfaces should be declared external.
|
||||
// TypeError: (15-36): Functions in interfaces must be declared external.
|
||||
// TypeError: (15-36): Constructor cannot be defined in interfaces.
|
||||
// TypeError: (15-36): Constructor must be implemented if declared.
|
||||
|
||||
@@ -3,6 +3,6 @@ interface I {
|
||||
}
|
||||
// ----
|
||||
// Warning: (15-35): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
|
||||
// Warning: (15-35): Functions in interfaces should be declared external.
|
||||
// TypeError: (15-35): Functions in interfaces must be declared external.
|
||||
// TypeError: (15-35): Constructor cannot be defined in interfaces.
|
||||
// TypeError: (15-35): Constructor must be implemented if declared.
|
||||
|
||||
+2
-3
@@ -1,7 +1,6 @@
|
||||
interface I {
|
||||
function f() public {
|
||||
function f() external pure {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (18-45): Functions in interfaces cannot have an implementation.
|
||||
// Warning: (18-45): Functions in interfaces should be declared external.
|
||||
// TypeError: (18-52): Functions in interfaces cannot have an implementation.
|
||||
|
||||
+1
-2
@@ -1,5 +1,4 @@
|
||||
interface I {
|
||||
function f(uint a) public returns (bool);
|
||||
function f(uint a) external returns (bool);
|
||||
}
|
||||
// ----
|
||||
// Warning: (18-59): Functions in interfaces should be declared external.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
interface Interface {
|
||||
function f() public;
|
||||
function f() external;
|
||||
}
|
||||
// ----
|
||||
// Warning: (23-43): Functions in interfaces should be declared external.
|
||||
|
||||
@@ -2,5 +2,4 @@ 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.
|
||||
// TypeError: (15-28): Functions in interfaces must be declared external.
|
||||
|
||||
@@ -2,4 +2,4 @@ interface I {
|
||||
function f() internal;
|
||||
}
|
||||
// ----
|
||||
// TypeError: (15-37): Functions in interfaces cannot be internal or private.
|
||||
// TypeError: (15-37): Functions in interfaces must be declared external.
|
||||
|
||||
@@ -2,4 +2,4 @@ interface I {
|
||||
function f() private;
|
||||
}
|
||||
// ----
|
||||
// TypeError: (15-36): Functions in interfaces cannot be internal or private.
|
||||
// TypeError: (15-36): Functions in interfaces must be declared external.
|
||||
|
||||
@@ -2,4 +2,4 @@ interface I {
|
||||
function f() public;
|
||||
}
|
||||
// ----
|
||||
// Warning: (15-35): Functions in interfaces should be declared external.
|
||||
// TypeError: (15-35): Functions in interfaces must be declared external.
|
||||
|
||||
Reference in New Issue
Block a user