mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Suggests external for fallback and interface functions.
This commit is contained in:
@@ -197,12 +197,24 @@ bool SyntaxChecker::visit(PlaceholderStatement const&)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SyntaxChecker::visit(ContractDefinition const& _contract)
|
||||
{
|
||||
m_isInterface = _contract.contractKind() == ContractDefinition::ContractKind::Interface;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SyntaxChecker::visit(FunctionDefinition const& _function)
|
||||
{
|
||||
bool const v050 = m_sourceUnit->annotation().experimentalFeatures.count(ExperimentalFeature::V050);
|
||||
|
||||
if (_function.noVisibilitySpecified())
|
||||
m_errorReporter.syntaxError(_function.location(), "No visibility specified.");
|
||||
{
|
||||
string suggestedVisibility = _function.isFallback() || m_isInterface ? "external" : "public";
|
||||
m_errorReporter.syntaxError(
|
||||
_function.location(),
|
||||
"No visibility specified. Did you intend to add \"" + suggestedVisibility + "\"?"
|
||||
);
|
||||
}
|
||||
|
||||
if (_function.isOldStyleConstructor())
|
||||
{
|
||||
|
||||
@@ -66,6 +66,7 @@ private:
|
||||
|
||||
virtual bool visit(PlaceholderStatement const& _placeholderStatement) override;
|
||||
|
||||
virtual bool visit(ContractDefinition const& _contract) override;
|
||||
virtual bool visit(FunctionDefinition const& _function) override;
|
||||
virtual bool visit(FunctionTypeName const& _node) override;
|
||||
|
||||
@@ -82,6 +83,7 @@ private:
|
||||
bool m_versionPragmaFound = false;
|
||||
|
||||
int m_inLoopDepth = 0;
|
||||
bool m_isInterface = false;
|
||||
|
||||
SourceUnit const* m_sourceUnit = nullptr;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user