diff options
author | John Hodge <tpg@mutabah.net> | 2016-11-23 11:36:23 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-11-23 11:36:23 +0800 |
commit | 28b1e61bd288a0e55cc0c6cb2d6c98be6983b0a1 (patch) | |
tree | 866702e46728eaa063dfdf20218dc6dcc5cc4e98 /src/resolve/index.cpp | |
parent | 5bc5d0122bf5f38ef394b9f3363995193c476530 (diff) | |
download | mrust-28b1e61bd288a0e55cc0c6cb2d6c98be6983b0a1.tar.gz |
Resolve - Place struct enum variants in the type namespace, fix serialisation bug
Diffstat (limited to 'src/resolve/index.cpp')
-rw-r--r-- | src/resolve/index.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/resolve/index.cpp b/src/resolve/index.cpp index 71da3b4e..c0276695 100644 --- a/src/resolve/index.cpp +++ b/src/resolve/index.cpp @@ -219,7 +219,21 @@ void Resolve_Index_Module_Base(const AST::Crate& crate, AST::Module& mod) ), (Static , _add_item_value(sp, mod, i.name, i.is_pub, i_data.path, !allow_collide); ), (Function, _add_item_value(sp, mod, i.name, i.is_pub, i_data.path, !allow_collide); ), - (EnumVar , _add_item_value(sp, mod, i.name, i.is_pub, i_data.path, !allow_collide); ) + (EnumVar , + bool is_struct = false; + if( e.enum_ ) { + ASSERT_BUG(sp, e.idx < e.enum_->variants().size(), "Variant out of range for " << i_data.path); + is_struct = e.enum_->variants().at(e.idx).m_data.is_Struct(); + } + else { + ASSERT_BUG(sp, e.idx < e.hir->m_variants.size(), "Variant out of range for " << i_data.path); + is_struct = e.hir->m_variants.at(e.idx).second.is_Struct(); + } + if( is_struct ) + _add_item_type(sp, mod, i.name, i.is_pub, i_data.path, !allow_collide); + else + _add_item_value(sp, mod, i.name, i.is_pub, i_data.path, !allow_collide); + ) ) } }; |