From f9efa417492916546d23115da7a55e86090d47dd Mon Sep 17 00:00:00 2001 From: Erik Kundt Date: Wed, 28 Mar 2018 18:10:32 +0200 Subject: [PATCH] Makes visibility warning more concise. --- libsolidity/analysis/StaticAnalyzer.cpp | 6 ++++-- .../syntaxTests/visibility/interface/function_default.sol | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/libsolidity/analysis/StaticAnalyzer.cpp b/libsolidity/analysis/StaticAnalyzer.cpp index 20464765b..d96f87484 100644 --- a/libsolidity/analysis/StaticAnalyzer.cpp +++ b/libsolidity/analysis/StaticAnalyzer.cpp @@ -51,12 +51,14 @@ void StaticAnalyzer::endVisit(ContractDefinition const&) 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())) + - "\"." + Declaration::visibilityToString(_function.visibility()) + + "\". " + + (isInterface ? "In interfaces it defaults to external." : "") ); if (_function.isImplemented()) m_currentFunction = &_function; diff --git a/test/libsolidity/syntaxTests/visibility/interface/function_default.sol b/test/libsolidity/syntaxTests/visibility/interface/function_default.sol index 9889d038a..7b9044dd2 100644 --- a/test/libsolidity/syntaxTests/visibility/interface/function_default.sol +++ b/test/libsolidity/syntaxTests/visibility/interface/function_default.sol @@ -3,4 +3,4 @@ interface I { } // ---- // Warning: Functions in interfaces should be declared external. -// Warning: No visibility specified. Defaulting to "external". +// Warning: No visibility specified. Defaulting to "public". In interfaces it defaults to external.