mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Defaults to external visibility for interfaces.
This commit is contained in:
parent
3bb54e8bd5
commit
8fe1cfb12e
@ -50,6 +50,14 @@ void StaticAnalyzer::endVisit(ContractDefinition const&)
|
|||||||
|
|
||||||
bool StaticAnalyzer::visit(FunctionDefinition const& _function)
|
bool StaticAnalyzer::visit(FunctionDefinition const& _function)
|
||||||
{
|
{
|
||||||
|
const bool isInterface = m_currentContract->contractKind() == ContractDefinition::ContractKind::Interface;
|
||||||
|
if (_function.noVisibilitySpecified())
|
||||||
|
m_errorReporter.warning(
|
||||||
|
_function.location(),
|
||||||
|
"No visibility specified. Defaulting to \"" +
|
||||||
|
(isInterface ? "external" : Declaration::visibilityToString(_function.visibility())) +
|
||||||
|
"\"."
|
||||||
|
);
|
||||||
if (_function.isImplemented())
|
if (_function.isImplemented())
|
||||||
m_currentFunction = &_function;
|
m_currentFunction = &_function;
|
||||||
else
|
else
|
||||||
|
@ -214,18 +214,9 @@ bool SyntaxChecker::visit(FunctionDefinition const& _function)
|
|||||||
{
|
{
|
||||||
bool const v050 = m_sourceUnit->annotation().experimentalFeatures.count(ExperimentalFeature::V050);
|
bool const v050 = m_sourceUnit->annotation().experimentalFeatures.count(ExperimentalFeature::V050);
|
||||||
|
|
||||||
if (_function.noVisibilitySpecified())
|
if (v050 && _function.noVisibilitySpecified())
|
||||||
{
|
|
||||||
if (v050)
|
|
||||||
m_errorReporter.syntaxError(_function.location(), "No visibility specified.");
|
m_errorReporter.syntaxError(_function.location(), "No visibility specified.");
|
||||||
else
|
|
||||||
m_errorReporter.warning(
|
|
||||||
_function.location(),
|
|
||||||
"No visibility specified. Defaulting to \"" +
|
|
||||||
Declaration::visibilityToString(_function.visibility()) +
|
|
||||||
"\"."
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
interface I {
|
||||||
|
function f();
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// Warning: Functions in interfaces should be declared external.
|
||||||
|
// Warning: No visibility specified. Defaulting to "external".
|
@ -0,0 +1,7 @@
|
|||||||
|
pragma experimental "v0.5.0";
|
||||||
|
interface I {
|
||||||
|
function f();
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// SyntaxError: No visibility specified.
|
||||||
|
// TypeError: Functions in interfaces must be declared external.
|
Loading…
Reference in New Issue
Block a user