diff options
Diffstat (limited to 'src/hir')
-rw-r--r-- | src/hir/from_ast.cpp | 23 | ||||
-rw-r--r-- | src/hir/from_ast_expr.cpp | 2 |
2 files changed, 20 insertions, 5 deletions
diff --git a/src/hir/from_ast.cpp b/src/hir/from_ast.cpp index 930c549f..dfe6b8ab 100644 --- a/src/hir/from_ast.cpp +++ b/src/hir/from_ast.cpp @@ -200,9 +200,16 @@ BUG(pat.span(), "Encountered StructTuple pattern not pointing to a enum variant or a struct - " << e.path); ), (EnumVar, - assert( pb.enum_ ); - const auto& var = pb.enum_->variants()[pb.idx].m_data; - unsigned int field_count = var.as_Tuple().m_sub_types.size(); + assert( pb.enum_ || pb.hir ); + unsigned int field_count; + if( pb.enum_ ) { + const auto& var = pb.enum_->variants()[pb.idx].m_data; + field_count = var.as_Tuple().m_sub_types.size(); + } + else { + const auto& var = pb.hir->m_variants.at(pb.idx).second; + field_count = var.as_Tuple().size(); + } ::std::vector<HIR::Pattern> sub_patterns; if( e.tup_pat.has_wildcard ) { @@ -240,8 +247,14 @@ }; ), (Struct, - assert( pb.struct_ ); - unsigned int field_count = pb.struct_->m_data.as_Tuple().ents.size(); + assert( pb.struct_ || pb.hir ); + unsigned int field_count; + if( pb.struct_ ) { + field_count = pb.struct_->m_data.as_Tuple().ents.size(); + } + else { + field_count = pb.hir->m_data.as_Tuple().size(); + } ::std::vector<HIR::Pattern> sub_patterns; if( e.tup_pat.has_wildcard ) { diff --git a/src/hir/from_ast_expr.cpp b/src/hir/from_ast_expr.cpp index a2d0be99..186ec232 100644 --- a/src/hir/from_ast_expr.cpp +++ b/src/hir/from_ast_expr.cpp @@ -559,6 +559,7 @@ struct LowerHIR_ExprNode_Visitor: m_rv.reset( new ::HIR::ExprNode_PathValue( v.span(), LowerHIR_Path(Span(v.get_pos()), v.m_path), ::HIR::ExprNode_PathValue::UNKNOWN ) ); ), (Struct, + assert( e.struct_ ); // TODO: Check the form and emit a PathValue if not a unit if( e.struct_->m_data.is_Struct() ) { // ERROR. @@ -577,6 +578,7 @@ struct LowerHIR_ExprNode_Visitor: m_rv.reset( new ::HIR::ExprNode_PathValue( v.span(), LowerHIR_Path(Span(v.get_pos()), v.m_path), ::HIR::ExprNode_PathValue::FUNCTION ) ); ), (Static, + assert( e.static_ ); if( e.static_->s_class() != ::AST::Static::CONST ) { m_rv.reset( new ::HIR::ExprNode_PathValue( v.span(), LowerHIR_Path(Span(v.get_pos()), v.m_path), ::HIR::ExprNode_PathValue::STATIC ) ); } |