diff options
author | John Hodge <tpg@mutabah.net> | 2016-03-22 15:31:59 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-03-22 15:31:59 +0800 |
commit | d6bd5627577df68efdb17ed908d76b8691963ac0 (patch) | |
tree | 1be0795b5bb791bdfed82e950b8d3d76f08c12cd /src | |
parent | 2db4633001c72f89de5073b26c6b8c3f1a19baa6 (diff) | |
download | mrust-d6bd5627577df68efdb17ed908d76b8691963ac0.tar.gz |
AST - Ignore None items when searching by name
Diffstat (limited to 'src')
-rw-r--r-- | src/ast/ast.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
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<Named<T> >::const_iterator find_named(const ::std::vector {
return ::std::find_if(vec.begin(), vec.end(), [&name](const Named<T>& 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); ),
|