From 5f20129e65f5b8b714189145d177067152a21ac1 Mon Sep 17 00:00:00 2001 From: chriseth Date: Fri, 9 Feb 2018 16:53:25 +0100 Subject: Scopes do not have to be declarations. --- libsolidity/ast/AST.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'libsolidity/ast/AST.cpp') 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::referencedSourceUnits(bool _recurse, set(scope) && dynamic_cast(scope)->m_scope) - scope = dynamic_cast(scope)->m_scope; - return dynamic_cast(*scope); + ASTNode const* s = scope(); + solAssert(s, ""); + // will not always be a declaratoion + while (dynamic_cast(s) && dynamic_cast(s)->scope()) + s = dynamic_cast(s)->scope(); + return dynamic_cast(*s); } string Declaration::sourceUnitName() const -- cgit