diff options
author | chriseth <chris@ethereum.org> | 2018-07-18 18:08:42 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-18 18:08:42 +0800 |
commit | b909df4573130e020c7f4dfb61c0571ba1bc02ab (patch) | |
tree | c5657726547d314fef6e80af702d061275afe5c7 /libsolidity/analysis/SyntaxChecker.cpp | |
parent | 1d33f41c1ab96746b97b97f79732ec23759fb8f0 (diff) | |
parent | 8b827af5bf4ed52c9612bcf1bdadb25ca7b879bf (diff) | |
download | dexon-solidity-b909df4573130e020c7f4dfb61c0571ba1bc02ab.tar.gz dexon-solidity-b909df4573130e020c7f4dfb61c0571ba1bc02ab.tar.zst dexon-solidity-b909df4573130e020c7f4dfb61c0571ba1bc02ab.zip |
Merge pull request #4430 from ethereum/enforceVisibilitySpecifier
[BREAKING] Enforce visibility specifier
Diffstat (limited to 'libsolidity/analysis/SyntaxChecker.cpp')
-rw-r--r-- | libsolidity/analysis/SyntaxChecker.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/libsolidity/analysis/SyntaxChecker.cpp b/libsolidity/analysis/SyntaxChecker.cpp index fba18a45..4d09e36d 100644 --- a/libsolidity/analysis/SyntaxChecker.cpp +++ b/libsolidity/analysis/SyntaxChecker.cpp @@ -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 (v050 && _function.noVisibilitySpecified()) - m_errorReporter.syntaxError(_function.location(), "No visibility specified."); + if (_function.noVisibilitySpecified()) + { + 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()) { |