From 0764a85f99e3c90516c4a3e994cf87875a494002 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sun, 8 Jan 2017 18:29:45 +0800 Subject: HIR Const Eval - Little fixes --- src/hir_conv/constant_evaluation.cpp | 5 ++++- src/hir_expand/const_eval_full.cpp | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/hir_conv/constant_evaluation.cpp b/src/hir_conv/constant_evaluation.cpp index 99e2629a..7318f2cf 100644 --- a/src/hir_conv/constant_evaluation.cpp +++ b/src/hir_conv/constant_evaluation.cpp @@ -328,8 +328,11 @@ namespace { } void visit(::HIR::ExprNode_BinOp& node) override { TRACE_FUNCTION_F("_BinOp"); + node.m_left->visit(*this); auto left = mv$(m_rv); + auto ret_type = mv$(m_rv_type); + node.m_right->visit(*this); auto right = mv$(m_rv); @@ -425,7 +428,7 @@ namespace { break; } - m_rv_type = m_exp_type.clone(); + m_rv_type = mv$(ret_type); } void visit(::HIR::ExprNode_UniOp& node) override { TRACE_FUNCTION_FR("_UniOp", m_rv); diff --git a/src/hir_expand/const_eval_full.cpp b/src/hir_expand/const_eval_full.cpp index 6e493aea..d2fa3a76 100644 --- a/src/hir_expand/const_eval_full.cpp +++ b/src/hir_expand/const_eval_full.cpp @@ -569,6 +569,14 @@ namespace { else { BUG(sp, "Invalid cast of " << inval.tag_str() << " to " << e.type); } + ), + (Borrow, + TU_IFLET( ::HIR::Literal, inval, BorrowOf, i, + val = mv$(inval); + ) + else { + BUG(sp, "Invalid cast of " << inval.tag_str() << " to " << e.type); + } ) ) ), -- cgit v1.2.3