Skip to content

Conversation

@davydog187
Copy link
Contributor

Implements the Lua load() function which compiles a string of Lua code and returns a function that executes it.

Features:

  • Compiles string chunks into executable functions
  • Returns nil + error message on parse/compile errors
  • Compiled functions can access global environment

Limitations:

  • Only supports string chunks (not reader functions)
  • Does not support chunkname, mode, or env parameters yet
  • Error messages include ANSI formatting (cosmetic issue)

Tests added for basic load functionality. Some tests are simplified due to current VM limitations with multi-assignment (a, b = f()) and multi-value table constructors ({f()}).

This enables running Lua 5.3 test suite files that use load() for dynamic code generation and testing.

Implements the Lua load() function which compiles a string of Lua
code and returns a function that executes it.

Features:
- Compiles string chunks into executable functions
- Returns nil + error message on parse/compile errors
- Compiled functions can access global environment

Limitations:
- Only supports string chunks (not reader functions)
- Does not support chunkname, mode, or env parameters yet
- Error messages include ANSI formatting (cosmetic issue)

Tests added for basic load functionality. Some tests are simplified
due to current VM limitations with multi-assignment (a, b = f()) and
multi-value table constructors ({f()}).

This enables running Lua 5.3 test suite files that use load() for
dynamic code generation and testing.
@davydog187 davydog187 force-pushed the implement-load-function branch from 72723f1 to 8bfcd9b Compare February 11, 2026 13:17
@davydog187 davydog187 merged commit e734f21 into main Feb 11, 2026
1 of 2 checks passed
@davydog187 davydog187 deleted the implement-load-function branch February 11, 2026 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant