Rhai v1.2.0 Release Notes

  • ๐Ÿ› Bug fixes (potentially script-breaking)

    • As originally intended, function calls with a bang (!) now operates directly on the caller's scope, allowing variables inside the scope to be mutated.
    • As originally intended, Engine::XXX_with_scope API's now properly propagate constants within the provided scope also to functions in the script.
    • ๐Ÿ–จ Printing of integral floating-point numbers is fixed (used to only prints 0.0).
    • func!() calls now work properly under no_closure.
    • ๐Ÿ›  Fixed parsing of unary negation such that expressions like if foo { ... } -x parses correctly.

    ๐Ÿ†• New features

    • ๐Ÿ”Œ #[cfg(...)] attributes can now be put directly on plugin functions or function defined in a plugin module.
    • ๐Ÿ“œ A custom syntax parser can now return a symbol starting with $$ to inform the implementation function which syntax variant was actually parsed.
    • AST::iter_literal_variables is added to extract all top-level literal constant/variable definitions from a script without running it.
    • Engine::call_fn_dynamic is deprecated and Engine::call_fn_raw is added which allows keeping new variables in the custom scope.

    โœจ Enhancements

    • Array methods now avoid cloning as much as possible (although most predicates will involve cloning anyway if passed a closure).
    • Array methods that take function pointers (e.g. closures) now optionally take the function name as a string.
    • Array adds the dedup method.
    • Array adds a sort method with no parameters which sorts homogeneous arrays of built-in comparable types (e.g. INT).
    • Inlining is disabled for error-path functions because errors are exceptional and scripts usually fail completely when an error is encountered.
    • โšก๏ธ The optimize module is completely eliminated under no_optimize, which should yield smaller code size.
    • NativeCallContext::position is added to return the position of the function call.
    • ๐Ÿ‘ฏ Scope::clone_visible is added that copies only the last instance of each variable, omitting all shadowed variables.

    ๐Ÿ—„ Deprecated API's

    • NativeCallContext::call_fn_dynamic_raw is deprecated and NativeCallContext::call_fn_raw is added.
    • ๐Ÿ—„ From<EvalAltResult> for Result<T, Box<EvalAltResult> > is deprecated so it will no longer be possible to do EvalAltResult::ErrorXXXXX.into() to convert to a Result; instead, Err(EvalAltResult:ErrorXXXXX.into()) must be used. Code is clearer if errors are explicitly wrapped in Err.