diff options
author | Leonardo Alt <leo@ethereum.org> | 2018-06-15 18:30:28 +0800 |
---|---|---|
committer | Leonardo Alt <leo@ethereum.org> | 2018-06-20 18:53:38 +0800 |
commit | 8862b3092bcdbcb8314ec27e2b11bf25fcc6346a (patch) | |
tree | 4570b3adc9678c944546144f5989629003422194 /libsolidity/analysis/ReferencesResolver.cpp | |
parent | ba7fbf11e72a4f9da149ac3c9b4c908e4f215250 (diff) | |
download | dexon-solidity-8862b3092bcdbcb8314ec27e2b11bf25fcc6346a.tar.gz dexon-solidity-8862b3092bcdbcb8314ec27e2b11bf25fcc6346a.tar.zst dexon-solidity-8862b3092bcdbcb8314ec27e2b11bf25fcc6346a.zip |
C99 scoping rules by default
Diffstat (limited to 'libsolidity/analysis/ReferencesResolver.cpp')
-rw-r--r-- | libsolidity/analysis/ReferencesResolver.cpp | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/libsolidity/analysis/ReferencesResolver.cpp b/libsolidity/analysis/ReferencesResolver.cpp index a051d7f9..58b659f7 100644 --- a/libsolidity/analysis/ReferencesResolver.cpp +++ b/libsolidity/analysis/ReferencesResolver.cpp @@ -48,9 +48,7 @@ bool ReferencesResolver::visit(Block const& _block) if (!m_resolveInsideCode) return false; m_experimental050Mode = _block.sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::V050); - // C99-scoped variables - if (m_experimental050Mode) - m_resolver.setScope(&_block); + m_resolver.setScope(&_block); return true; } @@ -59,9 +57,7 @@ void ReferencesResolver::endVisit(Block const& _block) if (!m_resolveInsideCode) return; - // C99-scoped variables - if (m_experimental050Mode) - m_resolver.setScope(_block.scope()); + m_resolver.setScope(_block.scope()); } bool ReferencesResolver::visit(ForStatement const& _for) @@ -69,9 +65,7 @@ bool ReferencesResolver::visit(ForStatement const& _for) if (!m_resolveInsideCode) return false; m_experimental050Mode = _for.sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::V050); - // C99-scoped variables - if (m_experimental050Mode) - m_resolver.setScope(&_for); + m_resolver.setScope(&_for); return true; } @@ -79,18 +73,16 @@ void ReferencesResolver::endVisit(ForStatement const& _for) { if (!m_resolveInsideCode) return; - if (m_experimental050Mode) - m_resolver.setScope(_for.scope()); + m_resolver.setScope(_for.scope()); } void ReferencesResolver::endVisit(VariableDeclarationStatement const& _varDeclStatement) { if (!m_resolveInsideCode) return; - if (m_experimental050Mode) - for (auto const& var: _varDeclStatement.declarations()) - if (var) - m_resolver.activateVariable(var->name()); + for (auto const& var: _varDeclStatement.declarations()) + if (var) + m_resolver.activateVariable(var->name()); } bool ReferencesResolver::visit(Identifier const& _identifier) @@ -99,9 +91,14 @@ bool ReferencesResolver::visit(Identifier const& _identifier) if (declarations.empty()) { string suggestions = m_resolver.similarNameSuggestions(_identifier.name()); - string errorMessage = - "Undeclared identifier." + - (suggestions.empty()? "": " Did you mean " + std::move(suggestions) + "?"); + string errorMessage = "Undeclared identifier."; + if (!suggestions.empty()) + { + if ("\"" + _identifier.name() + "\"" == suggestions) + errorMessage += " " + std::move(suggestions) + " is not (or not yet) visible at this point."; + else + errorMessage += " Did you mean " + std::move(suggestions) + "?"; + } declarationError(_identifier.location(), errorMessage); } else if (declarations.size() == 1) |