diff options
author | John Hodge <tpg@mutabah.net> | 2016-09-03 13:12:57 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-09-03 13:12:57 +0800 |
commit | 5b8ec18a7c2e85d4e0f8ebbbe24d816d0caa4a76 (patch) | |
tree | 36d9b8cdbe59ef9c63a6b2c66713823a7adf2427 /src | |
parent | 4d009c4193449c61aaf8f863f27043f15f8212f4 (diff) | |
download | mrust-5b8ec18a7c2e85d4e0f8ebbbe24d816d0caa4a76.tar.gz |
HIR From AST - Add an error message when invalid value found, earlier error for bad binding
Diffstat (limited to 'src')
-rw-r--r-- | src/hir/from_ast_expr.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/hir/from_ast_expr.cpp b/src/hir/from_ast_expr.cpp index 186ec232..415ff978 100644 --- a/src/hir/from_ast_expr.cpp +++ b/src/hir/from_ast_expr.cpp @@ -556,13 +556,17 @@ struct LowerHIR_ExprNode_Visitor: else { TU_MATCH_DEF(::AST::PathBinding, (v.m_path.binding()), (e), ( - m_rv.reset( new ::HIR::ExprNode_PathValue( v.span(), LowerHIR_Path(Span(v.get_pos()), v.m_path), ::HIR::ExprNode_PathValue::UNKNOWN ) ); + auto p = LowerHIR_Path(Span(v.get_pos()), v.m_path); + if( p.m_data.is_Generic() ) { + BUG(v.span(), "Unknown binding for PathValue but path is generic - " << v.m_path); + } + m_rv.reset( new ::HIR::ExprNode_PathValue( v.span(), mv$(p), ::HIR::ExprNode_PathValue::UNKNOWN ) ); ), (Struct, assert( e.struct_ ); - // TODO: Check the form and emit a PathValue if not a unit + // Check the form and emit a PathValue if not a unit if( e.struct_->m_data.is_Struct() ) { - // ERROR. + ERROR(v.span(), E0000, "Named value referring to a struct that isn't tuple-like or unit-like - " << v.m_path); } else if( e.struct_->m_data.as_Tuple().ents.size() > 0 ) { m_rv.reset( new ::HIR::ExprNode_PathValue( v.span(), LowerHIR_Path(Span(v.get_pos()), v.m_path), ::HIR::ExprNode_PathValue::STRUCT_CONSTR ) ); |