feat(phase-10): Polish & Remaining TODOs#134
Merged
davydog187 merged 1 commit intomainfrom Feb 11, 2026
Merged
Conversation
Completes Phase 10 of the Lua 5.3 VM implementation plan. ## Changes ### 1. Restored string.lower doctests (3 locations) Since string stdlib was implemented in Phase 5, restored the commented-out doctests in lib/lua.ex that demonstrate string.lower functionality: - call_function/3 doctest - Function reference doctest - API module doctest example ### 2. Implemented local function declarations (Statement.LocalFunc) Added compiler support for `local function name() ... end` syntax: - Scope resolver allocates register for local function name - Scope resolver processes function body scope - Codegen generates closure and stores in local register Limitations (marked as :skip in tests): - Self-recursive local functions not yet supported (requires upvalue self-reference) - Proper scope cleanup for nested scopes pending ### 3. Implemented do...end blocks (Statement.Do) Added compiler support for `do...end` blocks: - Scope resolver processes block body - Codegen generates block instructions Limitations (marked as :skip in tests): - Nested scope creation/cleanup not fully implemented ### 4. Comprehensive test coverage Added 9 new integration tests: - 4 tests for local function declarations - 5 tests for do...end blocks - 2 tests marked :skip for known limitations ## Test Results - All 1129 tests pass (up from 1120) - 34 skipped (up from 32) - 52 doctests, 14 properties ## Files Modified - lib/lua.ex — restored 3 string.lower doctests - lib/lua/compiler/codegen.ex — added LocalFunc and Do statement compilation - lib/lua/compiler/scope.ex — added LocalFunc and Do scope resolution - test/lua/compiler/integration_test.exs — added 9 new tests Implements Phase 10 from plan.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 10: Polish & Remaining TODOs
Completes the final phase of the Lua 5.3 VM implementation plan.
Summary
This PR addresses remaining TODOs from earlier phases and implements critical compiler gaps needed for the Lua 5.3 test suite.
Changes
1. Restored String Standard Library Doctests
Since the string stdlib was fully implemented in Phase 5, restored 3 commented-out doctests in
lib/lua.ex:call_function/3withstring.lowerstring.lowerstring.lowerAll doctests now pass successfully.
2. Local Function Declarations (
local function)Implemented compiler support for
local function name() ... endsyntax:Scope Resolution:
Code Generation:
Examples:
Known Limitations:
@tag :skipin tests3. Do...End Blocks
Implemented compiler support for
do...endblocks:Scope Resolution:
Code Generation:
Examples:
Known Limitations:
localdeclarations may shadow outer ones incorrectly@tag :skipin testsTesting
Added 9 new integration tests:
Test Results
Verification
mix formatcompletedmix compile --warnings-as-errorspassesmix testpasses (1129 tests, 0 failures)Impact on Lua 5.3 Test Suite
These compiler features unblock many Lua 5.3 test suite files that use:
local functiondeclarations (used inall.lua,api.lua,constructs.lua, etc.)do...endblocks for scoping (used throughout the test suite)While edge cases remain (recursion, nested scoping), the basic functionality enables significantly more test files to parse and run.
Next Steps
Future work to address limitations:
Implements Phase 10 from plan.md