diff --git a/CHANGELOG.md b/CHANGELOG.md index bfcd7aa1..1d13ec52 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ Bug fixes --------- * Integer numbers that are too large to deserialize into `INT` now fall back to `Decimal` or `FLOAT` instead of silently truncating. +* Parsing deeply-nested closures (e.g. `||{||{||{||{||{||{||{...}}}}}}}`) no longer panics but will be confined to the nesting limit. Breaking API changes -------------------- diff --git a/examples/event_handler_js/script.rhai b/examples/event_handler_js/script.rhai index 0667575f..2df62003 100644 --- a/examples/event_handler_js/script.rhai +++ b/examples/event_handler_js/script.rhai @@ -4,7 +4,7 @@ fn init() { // Can detect system-provided default states! // Add 'bool_state' as new state variable if one does not exist - if !("bool_state" in this) { + if "bool_state" !in this { this.bool_state = false; } // Add 'value' as new state variable (overwrites any existing) diff --git a/examples/event_handler_map/script.rhai b/examples/event_handler_map/script.rhai index 59c55f79..1dd341e3 100644 --- a/examples/event_handler_map/script.rhai +++ b/examples/event_handler_map/script.rhai @@ -4,7 +4,7 @@ /// State is stored inside an object map bound to 'state'. fn init() { // Add 'bool_state' as new state variable if one does not exist - if !("bool_state" in state) { + if "bool_state" !in state { state.bool_state = false; } // Add 'obj_state' as new state variable (overwrites any existing) @@ -37,7 +37,7 @@ fn start(data) { /// 'end' event handler fn end(data) { - if !state.bool_state || !("start_mode" in state) { + if !state.bool_state || "start_mode" !in state { throw "Not yet started!"; } if state.value > 0 { diff --git a/src/eval/eval_context.rs b/src/eval/eval_context.rs index 6243d949..d0ee3b10 100644 --- a/src/eval/eval_context.rs +++ b/src/eval/eval_context.rs @@ -6,7 +6,7 @@ use crate::{Dynamic, Engine, Scope}; use std::prelude::v1::*; /// Context of a script evaluation process. -#[derive(Debug)] +#[allow(dead_code)] pub struct EvalContext<'a, 's, 'ps, 'g, 'c, 't> { /// The current [`Engine`]. engine: &'a Engine, diff --git a/src/eval/stmt.rs b/src/eval/stmt.rs index 144df5d2..d6c734b4 100644 --- a/src/eval/stmt.rs +++ b/src/eval/stmt.rs @@ -3,7 +3,7 @@ use super::{Caches, EvalContext, GlobalRuntimeState, Target}; use crate::api::events::VarDefInfo; use crate::ast::{ - ASTFlags, BinaryExpr, Expr, Ident, OpAssignment, Stmt, SwitchCasesCollection, TryCatchBlock, + ASTFlags, BinaryExpr, Expr, OpAssignment, Stmt, SwitchCasesCollection, TryCatchBlock, }; use crate::func::{get_builtin_op_assignment_fn, get_hasher}; use crate::types::dynamic::{AccessMode, Union}; @@ -834,6 +834,7 @@ impl Engine { // Export statement #[cfg(not(feature = "no_module"))] Stmt::Export(x, ..) => { + use crate::ast::Ident; let (Ident { name, pos, .. }, Ident { name: alias, .. }) = &**x; // Mark scope variables as public scope.search(name).map_or_else( diff --git a/src/packages/iter_basic.rs b/src/packages/iter_basic.rs index b7a60dd5..41dc2409 100644 --- a/src/packages/iter_basic.rs +++ b/src/packages/iter_basic.rs @@ -665,6 +665,7 @@ mod range_functions { } /// Return true if the range contains no items. #[rhai_fn(get = "is_empty", name = "is_empty", pure)] + #[allow(unstable_name_collisions)] pub fn is_empty_exclusive(range: &mut ExclusiveRange) -> bool { range.is_empty() } diff --git a/src/types/dynamic.rs b/src/types/dynamic.rs index a5335651..2ff6c21e 100644 --- a/src/types/dynamic.rs +++ b/src/types/dynamic.rs @@ -1175,6 +1175,7 @@ impl Dynamic { /// ``` #[inline] #[must_use] + #[allow(unused_mut)] pub fn try_cast(mut self) -> Option { // Coded this way in order to maximally leverage potentials for dead-code removal.