mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #3038 from ethereum/interface-external
Force interface functions as external (0.5.0)
This commit is contained in:
commit
c35496bf4a
@ -9,6 +9,7 @@ Features:
|
|||||||
* Syntax Checker: Unary ``+`` is now a syntax error as experimental 0.5.0 feature.
|
* Syntax Checker: Unary ``+`` is now a syntax error as experimental 0.5.0 feature.
|
||||||
* Type Checker: Disallow non-pure constant state variables as experimental 0.5.0 feature.
|
* Type Checker: Disallow non-pure constant state variables as experimental 0.5.0 feature.
|
||||||
* Type Checker: Do not add members of ``address`` to contracts as experimental 0.5.0 feature.
|
* Type Checker: Do not add members of ``address`` to contracts as experimental 0.5.0 feature.
|
||||||
|
* Type Checker: Force interface functions to be external as experimental 0.5.0 feature.
|
||||||
* Type Checker: Require ``storage`` or ``memory`` keyword for local variables as experimental 0.5.0 feature.
|
* Type Checker: Require ``storage`` or ``memory`` keyword for local variables as experimental 0.5.0 feature.
|
||||||
|
|
||||||
Bugfixes:
|
Bugfixes:
|
||||||
|
@ -595,8 +595,16 @@ bool TypeChecker::visit(FunctionDefinition const& _function)
|
|||||||
{
|
{
|
||||||
if (_function.isImplemented())
|
if (_function.isImplemented())
|
||||||
m_errorReporter.typeError(_function.location(), "Functions in interfaces cannot have an implementation.");
|
m_errorReporter.typeError(_function.location(), "Functions in interfaces cannot have an implementation.");
|
||||||
if (_function.visibility() < FunctionDefinition::Visibility::Public)
|
if (_function.sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::V050))
|
||||||
m_errorReporter.typeError(_function.location(), "Functions in interfaces cannot be internal or private.");
|
{
|
||||||
|
if (_function.visibility() != FunctionDefinition::Visibility::External)
|
||||||
|
m_errorReporter.typeError(_function.location(), "Functions in interfaces must be declared external.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (_function.visibility() < FunctionDefinition::Visibility::Public)
|
||||||
|
m_errorReporter.typeError(_function.location(), "Functions in interfaces cannot be internal or private.");
|
||||||
|
}
|
||||||
if (_function.isConstructor())
|
if (_function.isConstructor())
|
||||||
m_errorReporter.typeError(_function.location(), "Constructor cannot be defined in interfaces.");
|
m_errorReporter.typeError(_function.location(), "Constructor cannot be defined in interfaces.");
|
||||||
}
|
}
|
||||||
|
@ -5879,6 +5879,28 @@ BOOST_AUTO_TEST_CASE(interface_function_bodies)
|
|||||||
CHECK_ERROR(text, TypeError, "Functions in interfaces cannot have an implementation");
|
CHECK_ERROR(text, TypeError, "Functions in interfaces cannot have an implementation");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(interface_function_external)
|
||||||
|
{
|
||||||
|
char const* text = R"(
|
||||||
|
pragma experimental "v0.5.0";
|
||||||
|
interface I {
|
||||||
|
function f() external;
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
success(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(interface_function_public)
|
||||||
|
{
|
||||||
|
char const* text = R"(
|
||||||
|
pragma experimental "v0.5.0";
|
||||||
|
interface I {
|
||||||
|
function f() public;
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
CHECK_ERROR(text, TypeError, "Functions in interfaces must be declared external.");
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(interface_function_internal)
|
BOOST_AUTO_TEST_CASE(interface_function_internal)
|
||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* text = R"(
|
||||||
|
Loading…
Reference in New Issue
Block a user