diff options
author | John Hodge <tpg@ucc.asn.au> | 2017-09-22 12:47:22 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2017-09-23 11:18:30 +0800 |
commit | 3e63ff7d57e90289e5c03c94002a0777d3f75b6a (patch) | |
tree | e11021572df6d0a53ed4e43571967eaf598e175b | |
parent | 1af51991c707e59979a244320b9264e8c1230925 (diff) | |
download | mrust-3e63ff7d57e90289e5c03c94002a0777d3f75b6a.tar.gz |
HIR Typecheck - Fix bug with get_full_path on functions in the root crate
-rw-r--r-- | src/hir/item_path.hpp | 6 | ||||
-rw-r--r-- | src/hir_typeck/outer.cpp | 2 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/hir/item_path.hpp b/src/hir/item_path.hpp index 9f9949e1..11e3b0f4 100644 --- a/src/hir/item_path.hpp +++ b/src/hir/item_path.hpp @@ -54,13 +54,17 @@ public: assert(parent); assert(name); - if( parent->name ) { + // If the parent has a name, or the parent is the crate root. + if( parent->name || !parent->ty ) { return get_simple_path(); } else if( parent->trait ) { + assert(parent->ty); + assert(parent->trait_params); return ::HIR::Path( parent->ty->clone(), ::HIR::GenericPath(parent->trait->clone(), parent->trait_params->clone()), ::std::string(name) ); } else { + assert(parent->ty); return ::HIR::Path( parent->ty->clone(), ::std::string(name) ); } } diff --git a/src/hir_typeck/outer.cpp b/src/hir_typeck/outer.cpp index 6358e47e..dddb7731 100644 --- a/src/hir_typeck/outer.cpp +++ b/src/hir_typeck/outer.cpp @@ -291,6 +291,8 @@ namespace { // If not, ensure taht we're checking a function return type, and error if not if( ! m_fcn_path ) ERROR(sp, E0000, "Use of an erased type outside of a function return - " << ty); + assert(m_fcn_ptr); + DEBUG(*m_fcn_path << " " << m_fcn_erased_count); ::HIR::PathParams params; for(unsigned int i = 0; i < m_fcn_ptr->m_params.m_types.size(); i ++) |