Merge pull request #191 from udoprog/error-shadowing

Avoid shadowing call errors in get_indexed_mut
This commit is contained in:
Stephen Chung 2020-07-25 15:15:49 +08:00 committed by GitHub
commit 7f7c3b44f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1052,17 +1052,20 @@ impl Engine {
#[cfg(not(feature = "no_index"))]
_ => {
let type_name = self.map_type_name(val.type_name());
let val_type_name = val.type_name();
let args = &mut [val, &mut idx];
self.exec_fn_call(
state, lib, FN_IDX_GET, true, 0, args, is_ref, true, None, level,
)
.map(|(v, _)| v.into())
.map_err(|_| {
.map_err(|e| match *e {
EvalAltResult::ErrorFunctionNotFound(..) => {
Box::new(EvalAltResult::ErrorIndexingType(
type_name.into(),
self.map_type_name(val_type_name).into(),
Position::none(),
))
}
_ => e,
})
}