Skip to content

Releases

Rulua 1.1 - Lua 5.1 syntax rules

Choose a tag to compare

@felipedaragon felipedaragon released this 30 Sep 11:15

Bug-fix release: string escapes and two syntax checks now behave exactly as in Lua 5.1.

rilua, the interpreter Rulua builds on, targets Lua 5.1 but treated unknown string escapes as errors, which is a Lua 5.2+ rule. Real Lua 5.1 scripts that rely on the lenient 5.1 behaviour, typically Windows paths such as "C:\Apps", failed to load with invalid escape sequence. This release restores the 5.1 rules and adds two 5.1 checks that rilua was missing.

Fixed

  • Unknown escape sequences are accepted again, as in Lua 5.1. "\A" is "A", so scripts with paths like "C:\Apps" load instead of failing. All 256 escape characters were checked against PUC-Rio 5.1.4.
  • ... outside a vararg function is now a syntax error, as in Lua 5.1 (rilua returned nil).
  • [[ nested inside [[...]] is now a syntax error, as in Lua 5.1 (nesting of [[...]] is deprecated).
  • String syntax errors quote the partial string (near '"abc'), matching PUC-Rio's messages.

Upgrading

Only the library changed. Replace lua5.1.dll, liblua5.1.so or liblua5.1.dylib with the one from your platform's package; nothing needs recompiling. The lua51.dll proxy, import libraries and headers are unchanged.

Verified

rilua's test suite (1,337 tests, including new ones for these rules), the differential C API tests, and the package self-tests on Windows x64 / Win32, Linux x86_64 / ARM64 and via the tracing kit.

Full changes: RILUA_PATCHES.diff (src/compiler/lexer.rs, src/compiler/parser.rs).

Rulua 1.0 — Lua 5.1, ported to Rust, binary-compatible with lua5.1.dll / .so / .dylib

Choose a tag to compare

@felipedaragon felipedaragon released this 27 Sep 14:21

First public release of Rulua, a port of the Lua 5.1 shared library to Rust. It is binary-compatible with the original PUC-Rio C library: it exports the complete Lua 5.1 C API (123 functions) with the same names and calling conventions, so existing programs and C modules built for Lua 5.1 load it without being recompiled.

Downloads

Platform Package Status
Windows x64 lua5.1-win64.zip in production use
Windows x86 (Win32) lua5.1-win32.zip tested (Windows 11 and Wine)
Windows ARM64 lua5.1-winarm64.zip preview: builds cleanly, not yet verified on ARM64 hardware
macOS Apple Silicon lua5.1-macos-arm64.tar.gz tested on real hardware (M3)
macOS Intel lua5.1-macos-x86_64.tar.gz tested on real hardware
Linux x86_64 lua5.1-linux-x86_64.tar.gz tested; needs glibc ≥ 2.28
Linux ARM64 lua5.1-linux-arm64.tar.gz tested (QEMU); needs glibc ≥ 2.28

Each package contains the library, import libraries (Windows) or headers, the stock lua interpreter linked to it, and a self-test. On Windows, packages also include a lua51.dll compatibility proxy.

Try it

Unpack and run the self-test. It compares the C API test output with the original PUC-Rio Lua 5.1.4:

run-tests.bat          (Windows)
./run-tests.sh         (macOS / Linux)

Add bench to also run the 26-test benchmark against the original interpreter.

Highlights

  • Full Lua 5.1 C API: C functions and closures, userdata with __gc, coroutines (including lua_yield from C), the debug API and hooks, and require of C modules.
  • Lua errors raised in C modules work with any compiler. On 32-bit Windows they use setjmp/longjmp like PUC-Rio, so modules built by MSVC or Delphi work too.
  • Verified by differential tests against PUC-Rio 5.1.4, plus the LPeg and lua-cjson test suites.
  • Performance: 1.5–2.4× slower than the original C Lua depending on the machine, and on Windows 1.24× faster than upstream rilua (up to 300× on very large strings).

Known differences

  • Language behaviour follows rilua, which targets Lua 5.1.1, so a few error messages are worded differently from 5.1.4.
  • PUC-Rio internal functions (luaD_*, luaH_*, …) are not provided. Only modules that bypass the public API use them.

See the README for details. Licensed under MIT OR Apache-2.0.