diff --git a/src/ast/stmt.rs b/src/ast/stmt.rs index abd5369f..10f21fb0 100644 --- a/src/ast/stmt.rs +++ b/src/ast/stmt.rs @@ -23,6 +23,8 @@ pub struct OpAssignment<'a> { /// Hash of the underlying operator call (for fallback). pub hash_op: u64, /// Op-assignment operator. + pub op_assign: &'a str, + /// Underlying operator. pub op: &'a str, } @@ -51,7 +53,8 @@ impl OpAssignment<'_> { Self { hash_op_assign: calc_fn_hash(op.literal_syntax(), 2), hash_op: calc_fn_hash(op_raw, 2), - op: op.literal_syntax(), + op_assign: op.literal_syntax(), + op: op_raw, } } /// Create a new [`OpAssignment`] from a base operator. diff --git a/src/eval/stmt.rs b/src/eval/stmt.rs index 403ddad6..81d47694 100644 --- a/src/eval/stmt.rs +++ b/src/eval/stmt.rs @@ -127,6 +127,7 @@ impl Engine { if let Some(OpAssignment { hash_op_assign, hash_op, + op_assign, op, }) = op_info { @@ -148,21 +149,23 @@ impl Engine { let hash = hash_op_assign; let args = &mut [lhs_ptr_inner, &mut new_val]; - match self.call_native_fn(global, state, lib, op, hash, args, true, true, op_pos) { + match self.call_native_fn( + global, state, lib, op_assign, hash, args, true, true, op_pos, + ) { Ok(_) => { #[cfg(not(feature = "unchecked"))] - self.check_data_size(&mut args[0], root.1)?; + self.check_data_size(&args[0], root.1)?; } - Err(err) if matches!(*err, ERR::ErrorFunctionNotFound(ref f, _) if f.starts_with(op)) => + Err(err) if matches!(*err, ERR::ErrorFunctionNotFound(ref f, _) if f.starts_with(op_assign)) => { // Expand to `var = var op rhs` - let op = &op[..op.len() - 1]; // extract operator without = - - // Run function let (value, _) = self.call_native_fn( global, state, lib, op, hash_op, args, true, false, op_pos, )?; + #[cfg(not(feature = "unchecked"))] + self.check_data_size(&value, root.1)?; + *args[0] = value.flatten(); } Err(err) => return Err(err),