Assignments return () and no compound assignments.
This commit is contained in:
@@ -1663,14 +1663,20 @@ impl Engine {
|
||||
Expr::Variable(_) => unreachable!(),
|
||||
// idx_lhs[idx_expr] op= rhs
|
||||
#[cfg(not(feature = "no_index"))]
|
||||
Expr::Index(_) => self.eval_dot_index_chain(
|
||||
scope, mods, state, lib, this_ptr, lhs_expr, level, new_val,
|
||||
),
|
||||
Expr::Index(_) => {
|
||||
self.eval_dot_index_chain(
|
||||
scope, mods, state, lib, this_ptr, lhs_expr, level, new_val,
|
||||
)?;
|
||||
Ok(Default::default())
|
||||
}
|
||||
// dot_lhs.dot_rhs op= rhs
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
Expr::Dot(_) => self.eval_dot_index_chain(
|
||||
scope, mods, state, lib, this_ptr, lhs_expr, level, new_val,
|
||||
),
|
||||
Expr::Dot(_) => {
|
||||
self.eval_dot_index_chain(
|
||||
scope, mods, state, lib, this_ptr, lhs_expr, level, new_val,
|
||||
)?;
|
||||
Ok(Default::default())
|
||||
}
|
||||
// Error assignment to constant
|
||||
expr if expr.is_constant() => {
|
||||
Err(Box::new(EvalAltResult::ErrorAssignmentToConstant(
|
||||
@@ -1965,15 +1971,7 @@ impl Engine {
|
||||
Stmt::Noop(_) => Ok(Default::default()),
|
||||
|
||||
// Expression as statement
|
||||
Stmt::Expr(expr) => {
|
||||
let result = self.eval_expr(scope, mods, state, lib, this_ptr, expr, level)?;
|
||||
|
||||
Ok(match expr.as_ref() {
|
||||
// If it is a simple assignment, erase the result at the root
|
||||
Expr::Assignment(_) => Default::default(),
|
||||
_ => result,
|
||||
})
|
||||
}
|
||||
Stmt::Expr(expr) => self.eval_expr(scope, mods, state, lib, this_ptr, expr, level),
|
||||
|
||||
// Block scope
|
||||
Stmt::Block(x) => {
|
||||
|
Reference in New Issue
Block a user