diff options
-rw-r--r-- | src/mir/check.cpp | 2 | ||||
-rw-r--r-- | src/mir/cleanup.cpp | 6 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/mir/check.cpp b/src/mir/check.cpp index 7d6b431a..9e83df8c 100644 --- a/src/mir/check.cpp +++ b/src/mir/check.cpp @@ -605,7 +605,7 @@ void MIR_Validate(const StaticTraitResolve& resolve, const ::HIR::ItemPath& path const auto& ty = state.get_lvalue_type(tmp, e.fcn.as_Value()); if( ! ty.m_data.is_Function() ) { - //MIR_BUG(state, "Call Fcn::Value with non-function type - " << ty); + MIR_BUG(state, "Call Fcn::Value with non-function type - " << ty); } } // Typecheck arguments and return value diff --git a/src/mir/cleanup.cpp b/src/mir/cleanup.cpp index 27410462..b2861b4f 100644 --- a/src/mir/cleanup.cpp +++ b/src/mir/cleanup.cpp @@ -1049,7 +1049,11 @@ void MIR_Cleanup(const StaticTraitResolve& resolve, const ::HIR::ItemPath& path, { e.args.push_back( ::MIR::LValue::make_Field({ box$(args_lvalue.clone()), i }) ); } - e.fcn = mv$(fcn_lvalue); + // If the trait is Fn/FnMut, dereference the input value. + if( pe.trait.m_path == resolve.m_lang_FnOnce ) + e.fcn = mv$(fcn_lvalue); + else + e.fcn = ::MIR::LValue::make_Deref({ box$(fcn_lvalue) }); } } ) |