Skip to content

Commit

Permalink
Fix crash.
Browse files Browse the repository at this point in the history
  • Loading branch information
schungx committed Mar 24, 2024
1 parent 875bf25 commit d920568
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Bug fixes
* The position of an undefined operation call now points to the operator instead of the first operand.
* The `optimize` command in `rhai-repl` now works properly and cycles through `None`->`Simple`->`Full`.
* `Engine::call_fn_XXX` no longer return errors unnecessarily wrapped in `EvalAltResult::ErrorInFunctionCall`.
* Some tests that panic on 32-bit architecture are fixed.

Deprecated API's
----------------
Expand Down
24 changes: 7 additions & 17 deletions src/eval/chaining.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,29 +482,19 @@ impl Engine {
}
// Short-circuit for indexing with literal: {expr}[1]
#[cfg(not(feature = "no_index"))]
(_, ChainType::Indexing) if rhs.is_constant() => {
idx_values.push(rhs.get_literal_value().unwrap())
}
#[cfg(not(feature = "no_index"))]
(Expr::FnCall(fnc, _), ChainType::Indexing)
if fnc.op_token == Some(crate::tokenizer::Token::InclusiveRange)
|| fnc.op_token == Some(crate::tokenizer::Token::ExclusiveRange) =>
{
(_, ChainType::Indexing) if rhs.get_literal_value().is_some() => {
idx_values.push(rhs.get_literal_value().unwrap())
}
// Short-circuit for simple method call: {expr}.func()
#[cfg(not(feature = "no_object"))]
(Expr::MethodCall(x, ..), ChainType::Dotting) if x.args.is_empty() => (),
// All other patterns - evaluate the arguments chain
_ => self.eval_dot_index_chain_arguments(
global,
caches,
scope,
this_ptr.as_deref_mut(),
expr,
rhs,
idx_values,
)?,
_ => {
let this_ptr = this_ptr.as_deref_mut();
self.eval_dot_index_chain_arguments(
global, caches, scope, this_ptr, expr, rhs, idx_values,
)?
}
}

match (lhs, new_val) {
Expand Down

0 comments on commit d920568

Please sign in to comment.