Rhai v1.7.0 Release Notes

  • ๐Ÿ› Bug fixes

    • Compound assignments now work properly with indexers.
    • Cloning a Scope no longer turns all constants to mutable.

    Script-breaking changes

    • Strict Variables Mode no longer returns an error when an undeclared variable matches a variable/constant in the provided external Scope.

    Potentially breaking API changes

    • The Engine::on_var and Engine::on_parse_token API's are now marked unstable/volatile.
    • The closures passed to Engine::on_var, Engine::on_def_var and Engine::register_debugger take EvalContext instead of &EvalContext or &mut EvalContext.
    • ๐Ÿ“‡ The following enum's are marked non_exhaustive: AccessMode, FnAccess, FnNamespace, FnMetadata, OptimizationLevel

    ๐Ÿ†• New API

    • Module::eval_ast_as_new_raw is made public as a low-level API.
    • format_map_as_json is provided globally, which is the same as to_json for object maps.
    • Engine::call_fn_raw_raw is added to add speed to repeated function calls.
    • Engine::eval_statements_raw is added to evaluate a sequence of statements.

    ๐Ÿ†• New features

    • A custom state is provided that is persistent during the entire evaluation run. This custom state is a Dynamic, which can hold any data, and can be accessed by the host via EvalContext::tag, EvalContext::tag_mut, NativeCallContext::tag and GlobalRuntimeState.tag.

    โœจ Enhancements

    • ๐Ÿ“œ Improper switch case condition syntax is now caught at parse time.
    • ๐Ÿ“œ Engine::parse_json now natively handles nested JSON inputs (using a token remap filter) without needing to replace { with #{.
    • ๐Ÿ‘ to_json is added to object maps to cheaply convert it to JSON format (() is mapped to null, all other data types must be supported by JSON)
    • FileModuleResolver now accepts a custom Scope to provide constants for optimization.
    • ๐Ÿ†• New variants, Start and End, are added to DebuggerEvent triggered at the start/end of script evaluation.