Refine error position for missing indexer.
This commit is contained in:
@@ -248,7 +248,6 @@ pub const FN_ANONYMOUS: &str = "anon$";
|
||||
pub const OP_EQUALS: &str = "==";
|
||||
|
||||
/// Standard method function for containment testing.
|
||||
///
|
||||
/// The `in` operator is implemented as a call to this method.
|
||||
pub const OP_CONTAINS: &str = "contains";
|
||||
|
||||
@@ -1293,10 +1292,11 @@ impl Engine {
|
||||
let hash_set =
|
||||
FnCallHashes::from_native(crate::calc_fn_hash(FN_IDX_SET, 3));
|
||||
let args = &mut [target, &mut idx_val_for_setter, &mut new_val];
|
||||
let pos = Position::NONE;
|
||||
|
||||
self.exec_fn_call(
|
||||
mods, state, lib, FN_IDX_SET, hash_set, args, is_ref, true,
|
||||
new_pos, None, level,
|
||||
mods, state, lib, FN_IDX_SET, hash_set, args, is_ref, true, pos,
|
||||
None, level,
|
||||
)?;
|
||||
}
|
||||
|
||||
@@ -1425,10 +1425,11 @@ impl Engine {
|
||||
let args = &mut [target, &mut name.into(), &mut new_val];
|
||||
let hash_set =
|
||||
FnCallHashes::from_native(crate::calc_fn_hash(FN_IDX_SET, 3));
|
||||
let pos = Position::NONE;
|
||||
|
||||
self.exec_fn_call(
|
||||
mods, state, lib, FN_IDX_SET, hash_set, args, is_ref, true,
|
||||
*pos, None, level,
|
||||
pos, None, level,
|
||||
)
|
||||
.map_err(
|
||||
|idx_err| match *idx_err {
|
||||
@@ -1972,6 +1973,7 @@ impl Engine {
|
||||
_ if indexers => {
|
||||
let args = &mut [target, &mut idx];
|
||||
let hash_get = FnCallHashes::from_native(crate::calc_fn_hash(FN_IDX_GET, 2));
|
||||
let idx_pos = Position::NONE;
|
||||
|
||||
self.exec_fn_call(
|
||||
mods, state, lib, FN_IDX_GET, hash_get, args, true, true, idx_pos, None, level,
|
||||
@@ -1980,7 +1982,11 @@ impl Engine {
|
||||
}
|
||||
|
||||
_ => EvalAltResult::ErrorIndexingType(
|
||||
self.map_type_name(target.type_name()).into(),
|
||||
format!(
|
||||
"{} [{}]",
|
||||
self.map_type_name(target.type_name()),
|
||||
self.map_type_name(idx.type_name())
|
||||
),
|
||||
Position::NONE,
|
||||
)
|
||||
.into(),
|
||||
|
Reference in New Issue
Block a user