From d6bd5627577df68efdb17ed908d76b8691963ac0 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Tue, 22 Mar 2016 15:31:59 +0800 Subject: AST - Ignore None items when searching by name --- src/ast/ast.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ast/ast.cpp b/src/ast/ast.cpp index 72b4455c..ea709be4 100644 --- a/src/ast/ast.cpp +++ b/src/ast/ast.cpp @@ -331,20 +331,20 @@ typename ::std::vector >::const_iterator find_named(const ::std::vector { return ::std::find_if(vec.begin(), vec.end(), [&name](const Named& x) { //DEBUG("find_named - x.name = " << x.name); - return x.name == name; + return x.name == name && !x.data.is_None(); }); } Module::ItemRef Module::find_item(const ::std::string& needle, bool allow_leaves, bool ignore_private_wildcard) const { - TRACE_FUNCTION_F("needle = " << needle); + TRACE_FUNCTION_F("path = " << m_my_path << ", needle = " << needle); { auto it = find_named(this->items(), needle); if( it != this->items().end() ) { TU_MATCH(::AST::Item, (it->data), (e), (None, - break; + throw ::std::runtime_error("BUG: Hit a None item"); ), (Module, return ItemRef(e); ), (Crate, return ItemRef(e.name); ), -- cgit v1.2.3