aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorLeonardo Alt <leo@ethereum.org>2018-07-06 17:04:30 +0800
committerLeonardo Alt <leo@ethereum.org>2018-07-11 00:54:46 +0800
commitc286cdaa6275442ed67dabd41b478cec5cf5b8ca (patch)
treea1ef45b30a0d3c116272967745dead4b29caac1a /libsolidity
parent0e9415bc31fa379b2c6cc8c8dba6b6ba1305391b (diff)
downloaddexon-solidity-c286cdaa6275442ed67dabd41b478cec5cf5b8ca.tar.gz
dexon-solidity-c286cdaa6275442ed67dabd41b478cec5cf5b8ca.tar.zst
dexon-solidity-c286cdaa6275442ed67dabd41b478cec5cf5b8ca.zip
Fix crash for double variable declaration in the same scope.
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/analysis/DeclarationContainer.cpp5
-rw-r--r--libsolidity/analysis/DeclarationContainer.h3
-rw-r--r--libsolidity/analysis/NameAndTypeResolver.cpp3
3 files changed, 10 insertions, 1 deletions
diff --git a/libsolidity/analysis/DeclarationContainer.cpp b/libsolidity/analysis/DeclarationContainer.cpp
index 786272e4..9e2bf6d3 100644
--- a/libsolidity/analysis/DeclarationContainer.cpp
+++ b/libsolidity/analysis/DeclarationContainer.cpp
@@ -96,6 +96,11 @@ void DeclarationContainer::activateVariable(ASTString const& _name)
m_invisibleDeclarations.erase(_name);
}
+bool DeclarationContainer::isInvisible(ASTString const& _name) const
+{
+ return m_invisibleDeclarations.count(_name);
+}
+
bool DeclarationContainer::registerDeclaration(
Declaration const& _declaration,
ASTString const* _name,
diff --git a/libsolidity/analysis/DeclarationContainer.h b/libsolidity/analysis/DeclarationContainer.h
index a3e0bd0a..9d7a17a3 100644
--- a/libsolidity/analysis/DeclarationContainer.h
+++ b/libsolidity/analysis/DeclarationContainer.h
@@ -62,6 +62,9 @@ public:
/// VariableDeclarationStatements.
void activateVariable(ASTString const& _name);
+ /// @returns true if declaration is currently invisible.
+ bool isInvisible(ASTString const& _name) const;
+
/// @returns existing declaration names similar to @a _name.
/// Searches this and all parent containers.
std::vector<ASTString> similarNames(ASTString const& _name) const;
diff --git a/libsolidity/analysis/NameAndTypeResolver.cpp b/libsolidity/analysis/NameAndTypeResolver.cpp
index b856544a..fce98f71 100644
--- a/libsolidity/analysis/NameAndTypeResolver.cpp
+++ b/libsolidity/analysis/NameAndTypeResolver.cpp
@@ -156,7 +156,8 @@ bool NameAndTypeResolver::updateDeclaration(Declaration const& _declaration)
void NameAndTypeResolver::activateVariable(string const& _name)
{
solAssert(m_currentScope, "");
- m_currentScope->activateVariable(_name);
+ if (m_currentScope->isInvisible(_name))
+ m_currentScope->activateVariable(_name);
}
vector<Declaration const*> NameAndTypeResolver::resolveName(ASTString const& _name, ASTNode const* _scope) const