Rhai

Languages & RuntimesApache-2.0

Embedded scripting language for Rust.

Latest v1.27.0 · by RhaiWritten in RustWebsiterhaiscript/rhaiRSS

Release activity

Release activity — 4 releases across 4 days in the last year. Each cell is one day; darker means more releases that day. Older weeks are hidden at this screen width.
AugSepOctNov
SundayNo releases on Aug 2, 2026No releases on Aug 9, 2026No releases on Aug 16, 2026No releases on Aug 23, 2026No releases on Aug 30, 2026No releases on Sep 6, 2026No releases on Sep 13, 2026No releases on Sep 20, 2026No releases on Sep 27, 2026No releases on Oct 4, 2026No releases on Oct 11, 2026No releases on Oct 18, 2026No releases on Oct 25, 2026No releases on Nov 1, 2026No releases on Nov 8, 2026No releases on Nov 15, 2026
MondayNo releases on Aug 3, 2026No releases on Aug 10, 2026No releases on Aug 17, 2026No releases on Aug 24, 2026No releases on Aug 31, 2026No releases on Sep 7, 2026No releases on Sep 14, 2026No releases on Sep 21, 2026No releases on Sep 28, 2026No releases on Oct 5, 2026No releases on Oct 12, 2026No releases on Oct 19, 2026No releases on Oct 26, 2026No releases on Nov 2, 2026No releases on Nov 9, 2026No releases on Nov 16, 2026
TuesdayNo releases on Aug 4, 2026No releases on Aug 11, 2026No releases on Aug 18, 20261 release on Aug 25, 2026No releases on Sep 1, 2026No releases on Sep 8, 2026No releases on Sep 15, 2026No releases on Sep 22, 2026No releases on Sep 29, 2026No releases on Oct 6, 2026No releases on Oct 13, 2026No releases on Oct 20, 2026No releases on Oct 27, 2026No releases on Nov 3, 2026No releases on Nov 10, 2026No releases on Nov 17, 2026
WednesdayNo releases on Aug 5, 2026No releases on Aug 12, 2026No releases on Aug 19, 2026No releases on Aug 26, 2026No releases on Sep 2, 2026No releases on Sep 9, 2026No releases on Sep 16, 2026No releases on Sep 23, 2026No releases on Sep 30, 2026No releases on Oct 7, 2026No releases on Oct 14, 20261 release on Oct 21, 2026No releases on Oct 28, 2026No releases on Nov 4, 2026No releases on Nov 11, 2026
ThursdayNo releases on Aug 6, 2026No releases on Aug 13, 2026No releases on Aug 20, 2026No releases on Aug 27, 2026No releases on Sep 3, 2026No releases on Sep 10, 2026No releases on Sep 17, 2026No releases on Sep 24, 2026No releases on Oct 1, 2026No releases on Oct 8, 2026No releases on Oct 15, 2026No releases on Oct 22, 2026No releases on Oct 29, 2026No releases on Nov 5, 2026No releases on Nov 12, 2026
FridayNo releases on Aug 7, 2026No releases on Aug 14, 2026No releases on Aug 21, 2026No releases on Aug 28, 2026No releases on Sep 4, 2026No releases on Sep 11, 2026No releases on Sep 18, 2026No releases on Sep 25, 2026No releases on Oct 2, 2026No releases on Oct 9, 2026No releases on Oct 16, 2026No releases on Oct 23, 2026No releases on Oct 30, 2026No releases on Nov 6, 2026No releases on Nov 13, 2026
SaturdayNo releases on Aug 8, 2026No releases on Aug 15, 2026No releases on Aug 22, 2026No releases on Aug 29, 2026No releases on Sep 5, 2026No releases on Sep 12, 2026No releases on Sep 19, 2026No releases on Sep 26, 2026No releases on Oct 3, 2026No releases on Oct 10, 2026No releases on Oct 17, 2026No releases on Oct 24, 2026No releases on Oct 31, 2026No releases on Nov 7, 2026No releases on Nov 14, 2026

4 releases in the last year

Changelog

v1.27.0Latest

Version 1.27.0

Added 8
  • A new no_ast feature excludes the AST, parser, tokenizer and optimizer from the build so that only Rhai Grain bytecodes can be run
  • Lazy-loaded modules are supported natively in all modes and only look up functions when called, reducing runtime footprint
  • Bare function names are supported as variables in Rhai Grain
  • Custom syntax that does not modify the scope is fully supported in Rhai Grain
  • Importing modules, the global:: namespace, and the export and import statements are supported by Rhai Grain
  • The Engine::on_map_missing_property callback works with Rhai Grain
  • The Engine::on_def_var callback works with Rhai Grain, with the nesting level reported by VarDefInfo always zero
  • rhai-run supports loading and executing Rhai Grain bytecode files when the grain feature is enabled
Changed 5
  • .call(fnptr, args...) and .curry(...) method calls now work in any position in a chain in Rhai Grain instead of only at the root
  • Rhai Grain bytecode transpilation is optimized
  • The Rhai Grain VM is at par or faster than the AST interpreter for index assignments and for scripts with callbacks
  • The Rhai Grain VM is 1.8-2x faster than the AST interpreter when running switch statements
  • The Rhai Grain VM is 2x faster than the AST interpreter when running !<bool> expressions
Fixed 11
  • A data-race condition in native function callbacks is fixed
  • Errors raised during built-in binary operations such as division by zero now contain proper Position information
  • Operation counts from scripted function callbacks invoked by native Rust functions are now reported to Engine::on_progress instead of being discarded
  • Capturing the caller's scope via call! with a function pointer now works properly in Rhai Grain
  • The .shared() method call now works properly in Rhai Grain
  • Constants in switch cases, arrays and object maps are now handled properly in Rhai Grain
Removed 1
  • The Rhai Grain transpiler and VM no longer carry the experimental qualifier and are now considered stable

From Rhai

This is a big release that officially remove the experimental qualifier to the Rhai Grain transpiler and VM.

A new feature, no_ast is added to completely remove the AST, parser, tokenizer and optimizer from the build. Such a build can only run Rhai Grain bytecodes; it cannot parse Rhai script text.

Lazy-loading is now also supported natively in all modes. Lazy-loaded modules only look up functions when they're being called, thus substantially cutting down runtime footprint.

There are a large number of bug fixes as well, in addition to some performance improvements.

Bug fixes
  • (Fuzzing) Fixed missing data-race condition in native function callbacks (#1161).
  • Errors raised during built-in binary operations (such as 100 / 0) now contain proper Position information (identified by Rhai Grain ).
  • Number of operations reported to Engine::on_progress now properly count scripted function calls from native Rust functions (identified by Rhai Grain). Previously all operation counts performed by a scripted function callback (including a closure) from a native Rust function are discarded.
  • Capturing the caller's scope via call!(fnptr, args...) now works properly in Rhai Grain.
  • .shared() method calls now work property in Rhai Grain.
  • Missing capabilities in scripts related to some constants (especially in switch cases, arrays and object maps) now work properly in Rhai Grain (thanks @yinho999 #1182).
  • Failed function resolutions are now cached properly for calls with other than two arguments - a regression from version 1.10 (thanks @ImTheSquid #1183).
  • A function resolution cache is now created (if none exists) when entering a block. Previously, a loop body evaluated with no cache yet would resolve every function call again on each iteration (thanks @ImTheSquid #1183).
  • Assigning a constant into a container variable (array, map etc.) now works properly without making the value read-only (thanks @cuervolu #1187).
  • Under sync, a method call on a shared variable with a closure argument that captures the same variable now raises ErrorDataRace, as it does without sync, instead of panicking while resolving the function. Dynamic::is_locked now returns true under sync when the value cannot be read, which includes being locked for write by the current thread (thanks @yuvalrakavy #1190).
  • A panic inside a native Rust function that takes its first argument by value, called with a variable first argument, now unwinds normally and can be caught by catch_unwind. Previously the copied first argument was restored only on the normal-return path, so the unwind tripped an internal assertion and the process aborted (thanks @yuvalrakavy #1189).
Rhai Grain is now at feature parity with the AST interpreter
  • Rhai Grain is no longer experimental.
  • New no_ast feature added that excludes the AST, its interpreter, the tokenizer, parser and optimizer for a minimized build (#1160). Under this feature flag, the Rhai Grain VM is the only venue to evaluate a script.
  • Bare function names are now supported as variables in Rhai Grain (#1158).
  • Custom syntax that does not modify the scope is now fully supported in Rhai Grain (#1173). Custom syntax that modifies the scope remains non-lowerable fragments.
  • Importing modules, the global:: namespace, the export and import statements are all supported by Rhai Grain (#1179).
  • The Engine::on_map_missing_property callback now works with Rhai Grain (#1164).
  • The Engine::on_def_var callback now works with Rhai Grain (#1170). However, the nesting level reported by VarDefInfo is always zero, since all nesting information is lost once the AST is lowered to bytecodes.
  • .call(fnptr, args...) and .curry(...) method calls now work in any position (instead of only on a chain's root) in Rhai Grain.
  • Rhai Grain bytecodes transpilation is optimized (thanks @ImTheSquid #1156).
  • Rhai Grain VM is now at par or faster than the AST interpreter for scripts index assignments (#1163).
  • Rhai Grain VM is now at par or faster than the AST interpreter for scripts with callbacks (#1159).
  • Rhai Grain VM is now 1.8-2x faster than the AST interpreter when running switch statements (#1162, #1165).
  • Rhai Grain VM is now 2x faster than the AST interpreter when running !<bool> expressions.
  • rhai-run now supports loading and executing Rhai Grain bytecode files if the grain feature is enabled (#1160).
  • The example grain_dump is now split into two CLI tools in bin: grain-compile, which compiles a Rhai script into Rhai Grain bytecodes, and grain-dump which dissembles a Rhai Grain bytecodes files (#1160).
  • grain-dump now disassembles Rhai Grain bytecodes files with more complete information (#1168).
Lazy loading of plugin module functions
  • Contributed by @ImTheSquid #1178.
  • Functions in plugin modules can now be resolved lazily: a Module can hold static manifests of plugin modules (generated via #[export_module(manifest)] and exported_manifest!) alongside its normal functions, and functions in manifests are not registered but looked up only when called.
  • Lazy-loading is opt-in.
  • Every package defined via def_package! now has a new_lazy constructor that keeps the functions of plugin modules within their manifests, looking them up only when called. For example, Engine::new_raw() with StandardPackage::new_lazy() uses about 16x less heap than Engine::new(), and builds the standard library about 8x faster, at the cost of slower function resolution the first time a function is called.
  • Lazy-load plugin's are supported by both the AST interpreter and Rhai Grain.
  • Use the new Module::from_manifest (the lazy exported_module!) or Module::combine_manifest (the lazy combine_with_exported_module!) API to create a lazy-loaded module or add the manifest of lazy-loaded functions to a module.
  • Module::register_lazy_functions registers all lazy-loaded functions up-front instead, for the same speed as before.
Feature flag to replace smartstring with compact_str
  • Contributed by @hoppworks #1175.
  • A new compact_str feature that uses compact_str instead of smartstring for identifiers and object map keys
  • smartstring is archived and unmaintained (RUSTSEC-2026-0249) and licensed under MPL-2.0+ (#897), whilecompact_str is licensed under the more permissive MIT.
  • Under compact_str, the key type of Map (and Identifier under internals) is CompactString instead of SmartString.
  • Under compact_str, serde-serializable types use CompactString directly instead of String since the serde feature of compact_str is no-std-safe, unlike that of smartstring.
  • compact_str is intended to become the default in version 2.0.
Enhancements
  • Added AGENTS.md files and a language reference cheat-sheet for AI (RHAI_CHEATSHEET.md).
  • String interpolation now resolves to_string with the evaluation's function resolution caches, instead of creating a new NativeCallContext (which cloned the global runtime state) for each interpolated value (thanks @ImTheSquid #1183).
View originalPermalink
How v1.27.0 went
v1.26.0

Version 1.26.0

Added 3
  • Add the experimental Rhai Grain bytecode compiler and VM, gated behind the `grain` feature flag, for fast evaluation of scripts
  • The `serde` and `metadata` features can now be used in `no-std` builds
  • Allow `no-std` builds for WASM
Changed 1
  • `BloomFilterU64` takes the size of its bit array as a `const` generic parameter instead of being hard-coded to 256 slots (32 bytes)
Fixed 6
  • Fix a serious optimizer bug that erroneously removed statements involving variable access which should be considered side effects
  • Fix function pointers called in method-call style with curried arguments, which were passed to native Rust functions in the wrong order
  • Fix `switch` statement failing to try ranges when all exact-match conditions fail
  • Fix `switch` statement failing to match shared values
  • Fix optimizer failing to optimize closures
  • Fix `Engine::compact_script` generating invalid compacted scripts due to missing spaces between ambiguous operators
View originalRead the notes
How v1.26.0 went
v1.25.0

Version 1.25.0

Added 5
  • A new advanced callback, Engine::on_missing_function, is added (gated under the internals feature) to override default handling when a called function or method is not found
  • A new method, EvalContext::new_frame, is added to create an isolated frame guard that automatically restores field values upon Drop
  • ${...} is supported in multi-line literal strings to escape interpolation, yielding literally ${...} for the string
  • FnPtr::call_fn_as_method and FnPtr::call_as_method_within_context are added (when not under no_object) to accept a this pointer for calling the function pointer as a method call
  • NativeCallContext::call_method and NativeCallContext::call_native_method are added (when not under no_object) to accept a this pointer for method calls
Changed 1
  • Procedural macros such as #[export_module] and #[derive(CustomType)] no longer require importing standard Rhai types
Fixed 4
  • Engine::compact_script now properly compacts scripts with custom syntax that uses $raw$
  • The string methods split, split_rev and their variants are now marked pure so they can be called on const strings
  • The array method index_of now falls back to value comparison for string argument when no script function of that name is registered
  • The walk API now correctly visits the arguments to MethodCall and switch statements
View originalRead the notes
How v1.25.0 went
v1.24.0

Version 1.24.0

Added 3
  • The array method sort is aliased to sort_by
  • Array methods sort_desc, order, order_by and order_desc are added
  • AST::new_from_module is added to create an AST from a shared Module
Changed 4
  • web-time is used for WASM targets instead of the unmaintained instant crate
  • The optimizer now optimizes constant object map property accesses
  • The optimizer turns nested if cond1 { if cond2 { ... } } into if cond1 && cond2 { ... }
  • An exception is thrown when attempting to use sort on an array containing unsupported element types
Fixed 1
  • Panic when using sort on an array with a comparer function that does not implement a total order
Removed 1
  • stdweb support is removed, along with the stdweb feature flag; use wasm-bindgen instead
View originalRead the notes
How v1.24.0 went
v1.23.0

Versions 1.23.3 and 1.23.4

Added 8
  • `NativeCallContext::call_source` is added to return the source of the caller
  • `CustomType` derive macro now supports generic types
  • `CustomType` derive macro now handles `Option` fields
  • `Engine::eval_fn_call` is added to make a generic function call
  • `Engine::eval_binary_op` is added to quickly compare two `Dynamic` values
  • The symbol types `$token$`, `$inner$`, and `$raw$` can now be used in custom syntax definitions
  • `Engine::register_custom_syntax_without_look_ahead_raw` is added to allow the use of `$raw$` in custom syntax, returning script text character-by-character without tokenizing
  • `CallFnOptions::in_all_namespaces` is added to allow calling functions in all namespaces, not only scripted functions in the `AST`
Changed 3
  • `build.rs` no longer writes to the source tree but to `OUT_DIR` instead
  • The `rhai_codegen` crate dependency is bumped to `3.0.0` or later
  • Better handling for 32-bit architectures and enhanced safety by replacing casts with `try_from`
Fixed 5
  • Fixed crash when using `..=` in arrays, BLOBs, bit-fields and iterators
  • Modules loaded within a `ModuleResolversCollection` now properly enable access to the `scope`
  • Registered functions for comparison operators with only one operand being a custom type now work properly
  • `NativeCallContext::fn_source` now correctly returns the source of the function (usually `None`)
  • `Engine::collect_fn_metadata` now properly includes functions registered into the global namespace
View originalRead the notes
How v1.23.0 went
v1.22.0

Version 1.22.0

Added 1
  • A new method `call_source` in `NativeCallContext` returns the source (if any) of the caller function
Changed 5
  • Epsilon-based floating-point comparisons have been revised
  • Unneeded optional dependencies are no longer pulled in with features
  • Function call error messages display the caller function's source together with line number info
  • `source` and `position` in `NativeCallContext` are renamed to `fn_source` and `call_position`
  • The `&&`, `||` and `??` operators are optimized to allow efficient chaining
Fixed 5
  • An integer-overflow bug from an inclusive range in `get_bits` is fixed
  • Nested functions marked `private` now properly cause compilation errors
  • Passing a function as a function pointer into a function in an imported module now correctly encapsulates the current environment into the generated function pointer
  • Passing a closure into a function in an imported module now correctly encapsulates the current environment
  • `Engine::collect_fn_metadata` now properly includes the namespaces of functions in static modules
View originalRead the notes
How v1.22.0 went

v1.21.0

Added 3
  • A function pointer (FnPtr) can be created that binds to a native Rust function or closure via FnPtr::from_dn and FnPtr::from_dyn_fn, and calling it in script invokes the embedded function
  • The methods call_fn, call_native_fn, call_fn_raw and call_native_fn_raw are added to EvalContext
  • A new internals function, Engine::collect_fn_metadata, collects all functions metadata to facilitate better error reporting for missing functions
Changed 1
  • The get_fn_metadata_list function is marked volatile
Fixed 2
  • Fixed bug in raw strings
  • no-std plus sync now builds correctly
View originalRead the notes
How v1.21.0 went

v1.20.1

Changed 1
  • If a string slice refers to the entire string, the slice is not cloned but returned as-is
Fixed 1
  • Fixed bug in raw strings with newlines
View originalRead the notes
How v1.20.1 went

v1.20.0

Added 2
  • Added support for raw strings with the syntax ##..#" ... "#..##
  • Added as_immutable_string_ref, as_array_ref, as_blob_ref, and as_map_ref plus their _mut variants for Dynamic
Changed 1
  • The break, return and throw statements can now be used directly as switch case statement expressions without being wrapped in a block
Fixed 5
  • Fixed an integer-overflow bug from an inclusive range in the bits iterator
  • Fixed an integer-underflow bug from an inclusive range
  • Strings are copied when the strings interner is busy instead of panicking
  • Deserialization of Scope now works correctly
  • Support for thumbv6m target is fixed
View originalRead the notes
How v1.20.0 went

v1.19.0

Added 4
  • Missing min and max functions are added where both operands are floats or Decimal
  • The break, continue, return and throw statements can now follow the ?? operator to short-circuit operations where the value is ()
  • A new symbol, $func$, is added to custom syntax to allow parsing of anonymous functions
  • The filter, drain and retain methods are added to object maps
Fixed 8
  • Variable resolver now correctly resolves variables that are captured in a closure
  • NativeCallContext with a lifetime parameter now parses correctly in the #[export_module] macro, allowing rust_2018_idioms lints
  • The sync feature now works properly in no-std builds
  • More data-race conditions are caught and returned as errors instead of panicking
  • Stack overflow when calling closures recursively is fixed
  • Engine::call_fn and Engine::call_fn_with_options now correctly use the AST's source field
  • Crash when using ..= in strings is fixed (found by fuzzing)
  • A recursive stack-overflow bug in Dynamic::is_hashable is fixed (found by fuzzing)
View originalRead the notes
How v1.19.0 went

v1.18.0

Added 7
  • Sub-strings can now be selected from full strings by indexing via ranges, e.g. s[1..4]
  • Doc-comments are now automatically added to function registrations and custom types via the CustomType derive macro
  • New options Engine::set_max_strings_interned and Engine::max_strings_interned are added to limit the maximum number of strings interned in the Engine's string interner
  • A new advanced callback, Engine::on_invalid_array_index, is added (gated under the internals feature) to handle access to missing properties in object maps
  • A new advanced callback, Engine::on_missing_map_property, is added (gated under the internals feature) to handle out-of-bound index into arrays
  • FuncRegistration::in_global_namespace and FuncRegistration::in_internal_namespace are added to avoid pulling in FnNamespace
  • LexError::Runtime is added for use with Engine::on_parse_token
Changed 3
  • parse_json is also available without the metadata or serde feature, using Engine::parse_json to parse the JSON text
  • Array, BLOB, and string iterators are also defined within the BasicIteratorPackage in addition to the regular array, BLOB, and string packages
  • Shared values under sync no longer deadlock and hang indefinitely; instead they spin for a number of tries, waiting one second between each, then error out
Fixed 5
  • 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, and Full
  • Engine::call_fn_XXX no longer returns errors unnecessarily wrapped in EvalAltResult::ErrorInFunctionCall
  • Some tests that panic on 32-bit architecture are fixed
  • The optimizer no longer goes into an infinite loop when optimizing a try statement with an empty body
Deprecated 1
  • The plugin macros export_fn, register_exported_fn!, set_exported_fn!, and set_exported_global_fn! are deprecated because they do not add value over existing direct APIs
View originalRead the notes
How v1.18.0 went
View all

Discussion

If you publish Rhai, you can claim this product by proving you administer its repository.