From 4ca6e7bdbefa83f8701f1303b6acbfbec152bbf2 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sat, 13 Aug 2016 14:05:03 +0800 Subject: MIR Gen - Correct bounds for assignment operator overloads --- src/mir/from_hir.cpp | 78 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 60 insertions(+), 18 deletions(-) (limited to 'src/mir/from_hir.cpp') diff --git a/src/mir/from_hir.cpp b/src/mir/from_hir.cpp index 79e20e50..ed405933 100644 --- a/src/mir/from_hir.cpp +++ b/src/mir/from_hir.cpp @@ -316,29 +316,16 @@ namespace { const auto& ty_slot = node.m_slot->m_res_type; const auto& ty_val = node.m_value->m_res_type; - ASSERT_BUG(sp, ty_slot == ty_val, "Types must match for assignment - " << ty_slot << " != " << ty_val); if( node.m_op != ::HIR::ExprNode_Assign::Op::None ) { - TU_IFLET(::HIR::TypeRef::Data, ty_slot.m_data, Primitive, e, - switch(e) - { - case ::HIR::CoreType::Char: - case ::HIR::CoreType::Str: - case ::HIR::CoreType::Bool: - BUG(sp, "Unsupported type for op-assign - " << ty_slot); - break; - default: - // Good. - break; - } - ) - else { - BUG(sp, "Unsupported type for op-assign - " << ty_slot); - } - auto val_lv = m_builder.lvalue_or_temp( ty_val, mv$(val) ); + ASSERT_BUG(sp, ty_slot.m_data.is_Primitive(), "Assignment operator overloads are only valid on primitives - ty_slot="<