diff options
author | John Hodge <tpg@mutabah.net> | 2016-11-17 15:42:37 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-11-17 15:42:37 +0800 |
commit | d8371fadef66162230b8610a255739f6bb7dca4d (patch) | |
tree | 195976f7a7876ddb6de584931a84dbbb85a93663 | |
parent | ee88b79f163a699b6e9123fa322e906c5f95aa66 (diff) | |
download | mrust-d8371fadef66162230b8610a255739f6bb7dca4d.tar.gz |
HIR - Fix bad handling of split slice patterns
-rw-r--r-- | src/hir/from_ast.cpp | 4 | ||||
-rw-r--r-- | src/hir_typeck/expr_cs.cpp | 4 | ||||
-rw-r--r-- | src/resolve/absolute.cpp | 2 |
3 files changed, 6 insertions, 4 deletions
diff --git a/src/hir/from_ast.cpp b/src/hir/from_ast.cpp index af5e6118..d45c7ba3 100644 --- a/src/hir/from_ast.cpp +++ b/src/hir/from_ast.cpp @@ -452,9 +452,9 @@ trailing.push_back( LowerHIR_Pattern(sp) ); auto extra_bind = e.extra_bind.is_valid() - ? ::HIR::PatternBinding() // TODO: Share code with the outer binding code - : ::HIR::PatternBinding(false, ::HIR::PatternBinding::Type::Ref, e.extra_bind.m_name.name, e.extra_bind.m_slot) + ? ::HIR::PatternBinding(false, ::HIR::PatternBinding::Type::Ref, e.extra_bind.m_name.name, e.extra_bind.m_slot) + : ::HIR::PatternBinding() ; return ::HIR::Pattern { diff --git a/src/hir_typeck/expr_cs.cpp b/src/hir_typeck/expr_cs.cpp index f90f6be8..1a320bdf 100644 --- a/src/hir_typeck/expr_cs.cpp +++ b/src/hir_typeck/expr_cs.cpp @@ -3766,6 +3766,8 @@ void Context::possible_equate_type_disable(unsigned int ivar_index, bool is_to) } void Context::add_var(unsigned int index, const ::std::string& name, ::HIR::TypeRef type) { + DEBUG("(" << index << " " << name << " : " << type << ")"); + assert(index != ~0u); if( m_bindings.size() <= index ) m_bindings.resize(index+1); m_bindings[index] = Binding { name, mv$(type) }; @@ -3776,7 +3778,7 @@ const ::HIR::TypeRef& Context::get_var(const Span& sp, unsigned int idx) const { return this->m_bindings[idx].ty; } else { - BUG(sp, "get_var - Binding index out of range"); + BUG(sp, "get_var - Binding index out of range - " << idx << " >=" << this->m_bindings.size()); } } diff --git a/src/resolve/absolute.cpp b/src/resolve/absolute.cpp index 788a1392..60b6c193 100644 --- a/src/resolve/absolute.cpp +++ b/src/resolve/absolute.cpp @@ -1790,7 +1790,7 @@ void Resolve_Absolute_Pattern(Context& context, bool allow_refutable, ::AST::Pa for(auto& sp : e.leading) Resolve_Absolute_Pattern(context, allow_refutable, sp); if( e.extra_bind.is_valid() ) { - context.push_var( pat.span(), e.extra_bind.m_name ); + e.extra_bind.m_slot = context.push_var( pat.span(), e.extra_bind.m_name ); } for(auto& sp : e.trailing) Resolve_Absolute_Pattern(context, allow_refutable, sp); |