diff options
author | John Hodge <tpg@mutabah.net> | 2016-11-08 15:05:59 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-11-08 15:05:59 +0800 |
commit | d6171134e39558505d05d7339e507c61254a1faa (patch) | |
tree | 77f80653273f05da6a75f93bd7de7107e244fe4d /src | |
parent | a357c00537622cbf1d62833b3fdefb3a83006ec1 (diff) | |
download | mrust-d6171134e39558505d05d7339e507c61254a1faa.tar.gz |
Resolve Absolute - Handle crate-root paths, fix an edge-case bug
Diffstat (limited to 'src')
-rw-r--r-- | src/resolve/absolute.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/resolve/absolute.cpp b/src/resolve/absolute.cpp index 120f1b3a..5c06ee39 100644 --- a/src/resolve/absolute.cpp +++ b/src/resolve/absolute.cpp @@ -779,10 +779,22 @@ namespace { TRACE_FUNCTION_FR(path << " start=" << start, path); auto& path_abs = path.m_class.as_Absolute(); + if( path_abs.nodes.empty() ) { + switch(mode) + { + case Context::LookupMode::Namespace: + path.bind( ::AST::PathBinding::make_Module({nullptr, &crate.m_hir->m_root_module}) ); + return ; + default: + TODO(sp, ""); + } + } + const ::HIR::Module* hmod = &crate.m_hir->m_root_module; for(unsigned int i = start; i < path_abs.nodes.size() - 1; i ++ ) { auto& n = path_abs.nodes[i]; + assert(hmod); auto it = hmod->m_mod_items.find(n.name()); if( it == hmod->m_mod_items.end() ) ERROR(sp, E0000, "Couldn't find path component '" << n.name() << "' of " << path); @@ -887,7 +899,8 @@ namespace { } } // TODO: Set binding - path = split_into_ufcs_ty(sp, mv$(path), i); + path = split_into_crate(sp, mv$(path), start, crate.m_name); + path = split_into_ufcs_ty(sp, mv$(path), i-start); return Resolve_Absolute_Path_BindUFCS(context, sp, mode, path); ) ) @@ -961,7 +974,8 @@ namespace { ( ), (Import, - TODO(sp, "Imports in HIR val items - " << e.path); + Resolve_Absolute_Path_BindAbsolute__hir_from_import(context, sp, true, path, e.path); + return ; ), (Constant, // Bind and update path |