diff options
author | chriseth <chris@ethereum.org> | 2018-02-09 23:53:25 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2018-02-27 19:17:25 +0800 |
commit | 5f20129e65f5b8b714189145d177067152a21ac1 (patch) | |
tree | 26c56df153f67bc2bf0f370216a81b314ec4987f /libsolidity/ast/AST.cpp | |
parent | 53289e15a2e1ea540a0c3abe28219c326a614fe5 (diff) | |
download | dexon-solidity-5f20129e65f5b8b714189145d177067152a21ac1.tar.gz dexon-solidity-5f20129e65f5b8b714189145d177067152a21ac1.tar.zst dexon-solidity-5f20129e65f5b8b714189145d177067152a21ac1.zip |
Scopes do not have to be declarations.
Diffstat (limited to 'libsolidity/ast/AST.cpp')
-rw-r--r-- | libsolidity/ast/AST.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp index 8da6964e..af007908 100644 --- a/libsolidity/ast/AST.cpp +++ b/libsolidity/ast/AST.cpp @@ -98,11 +98,12 @@ set<SourceUnit const*> SourceUnit::referencedSourceUnits(bool _recurse, set<Sour SourceUnit const& Declaration::sourceUnit() const { - solAssert(!!m_scope, ""); - ASTNode const* scope = m_scope; - while (dynamic_cast<Declaration const*>(scope) && dynamic_cast<Declaration const*>(scope)->m_scope) - scope = dynamic_cast<Declaration const*>(scope)->m_scope; - return dynamic_cast<SourceUnit const&>(*scope); + ASTNode const* s = scope(); + solAssert(s, ""); + // will not always be a declaratoion + while (dynamic_cast<Scopable const*>(s) && dynamic_cast<Scopable const*>(s)->scope()) + s = dynamic_cast<Scopable const*>(s)->scope(); + return dynamic_cast<SourceUnit const&>(*s); } string Declaration::sourceUnitName() const |