diff options
author | John Hodge <tpg@mutabah.net> | 2016-07-31 17:17:15 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-07-31 17:17:15 +0800 |
commit | a0435a53a38f59c2d69d7bea6a4628e0e195c850 (patch) | |
tree | f8912b07554cb9bc16ff50be8c5eea0a80387704 | |
parent | 9f75a160237871cb6704e3ca59eebb7b3e454789 (diff) | |
download | mrust-a0435a53a38f59c2d69d7bea6a4628e0e195c850.tar.gz |
HIR Typecheck CS - Keep track of closure return type
-rw-r--r-- | src/hir_typeck/expr_cs.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/hir_typeck/expr_cs.cpp b/src/hir_typeck/expr_cs.cpp index b5ee0b03..72b4e9a8 100644 --- a/src/hir_typeck/expr_cs.cpp +++ b/src/hir_typeck/expr_cs.cpp @@ -356,6 +356,7 @@ namespace { { Context& context; const ::HIR::TypeRef& ret_type; + ::std::vector< const ::HIR::TypeRef*> closure_ret_types; // TEMP: List of in-scope traits for buildup ::HIR::t_trait_list m_traits; @@ -394,7 +395,12 @@ namespace { TRACE_FUNCTION_F(&node << " return ..."); this->context.add_ivars( node.m_value->m_res_type ); - this->context.equate_types_coerce(node.span(), this->ret_type, node.m_value); + if( this->closure_ret_types.size() > 0 ) { + this->context.equate_types_coerce(node.span(), *this->closure_ret_types.back(), node.m_value); + } + else { + this->context.equate_types_coerce(node.span(), this->ret_type, node.m_value); + } node.m_value->visit( *this ); } @@ -1243,7 +1249,9 @@ namespace { this->context.equate_types_coerce( node.span(), node.m_return, node.m_code ); + this->closure_ret_types.push_back( &node.m_return ); node.m_code->visit( *this ); + this->closure_ret_types.pop_back( ); } private: |