Skip to content

Commit

Permalink
Visit structs only once.
Browse files Browse the repository at this point in the history
  • Loading branch information
chriseth committed Mar 21, 2017
1 parent 96c09fc commit 5ced3af
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions libsolidity/analysis/TypeChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ bool TypeChecker::visit(ContractDefinition const& _contract)
{
m_scope = &_contract;

// We force our own visiting order here.
//@TODO structs will be visited again below, but it is probably fine.
// We force our own visiting order here. The structs have to be excluded below.
set<ASTNode const*> visited;
for (auto const& s: _contract.definedStructs())
visited.insert(s);
ASTNode::listAccept(_contract.definedStructs(), *this);
ASTNode::listAccept(_contract.baseContracts(), *this);

Expand Down Expand Up @@ -113,7 +115,9 @@ bool TypeChecker::visit(ContractDefinition const& _contract)
_contract.annotation().isFullyImplemented = false;
}

ASTNode::listAccept(_contract.subNodes(), *this);
for (auto const& n: _contract.subNodes())
if (!visited.count(n.get()))
n->accept(*this);

checkContractExternalTypeClashes(_contract);
// check for hash collisions in function signatures
Expand Down

0 comments on commit 5ced3af

Please sign in to comment.