diff options
author | John Hodge <tpg@mutabah.net> | 2016-08-01 13:24:00 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-08-01 13:24:00 +0800 |
commit | dc4d17fb2edc6cd68e31632484ad01d470984934 (patch) | |
tree | 2195d3491d0e0dfe407f018f4b1b5760dac0722b | |
parent | fc4c8a1e3d2994b24bc4f7f573d49be99c1dabcf (diff) | |
download | mrust-dc4d17fb2edc6cd68e31632484ad01d470984934.tar.gz |
HIR Typecheck CS - Don't coerce on let unless type is specified
-rw-r--r-- | src/hir_typeck/expr_cs.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/hir_typeck/expr_cs.cpp b/src/hir_typeck/expr_cs.cpp index 792007fb..f051b0b8 100644 --- a/src/hir_typeck/expr_cs.cpp +++ b/src/hir_typeck/expr_cs.cpp @@ -433,7 +433,14 @@ namespace { if( node.m_value ) { this->context.add_ivars( node.m_value->m_res_type ); - this->context.equate_types_coerce( node.span(), node.m_type, node.m_value ); + // If the type was omitted or was just `_`, equate + if( node.m_type.m_data.is_Infer() ) { + this->context.equate_types( node.span(), node.m_type, node.m_value->m_res_type ); + } + // otherwise coercions apply + else { + this->context.equate_types_coerce( node.span(), node.m_type, node.m_value ); + } node.m_value->visit( *this ); } |