feat(phase-17): Vararg expansion, scope fixes, and suite triage#141
Open
davydog187 wants to merge 3 commits intomainfrom
Open
feat(phase-17): Vararg expansion, scope fixes, and suite triage#141davydog187 wants to merge 3 commits intomainfrom
davydog187 wants to merge 3 commits intomainfrom
Conversation
Implement multi-return expansion across call arguments, table constructors, and return statements using state.multi_return_count tracking. Fix floor division/modulo to use Lua 5.3 floor semantics. Add _ENV support, fix assert to return all args, support hex float literals, fix local function redefinition scoping, and fix table.unpack nil handling. Suite tests passing: 3/29 (simple_test.lua, api.lua, code.lua) Tests: 1257 passing, 0 failures, 33 skipped Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…degen improvements Major fixes: - Fix for-loop register allocation: reserve 3 registers in scope for internal counter/limit/step to prevent body local conflicts - Fix upvalue nesting: rewrite find_upvalue as ensure_upvalue for correct 3+ level upvalue chain resolution - Move open_upvalues to State struct for proper persistence through loops - Per-iteration clearing of loop-local open_upvalue entries - Vararg expansion in local/regular multi-assignment (local a,b,c = ...) - Main chunk marked as vararg per Lua 5.3 spec (enables load() varargs) - FuncDecl dotted names: emit closure instructions, use gen_var_by_name for local table lookups - Temp register recycling in gen_block to prevent register overflow - max_registers uses peak next_reg from codegen (not just scope locals) - Float literal parsing: .0, 0., 2.E-1 now valid - string.packsize implementation Suite progress: 4/29 passing (simple_test, api, code, vararg) Test count: 1273 tests, 0 failures, 32 skipped Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
Major improvements for Lua 5.3 compliance:
Multi-Return & Vararg Expansion
local a, b, c = ...)f(a, b, ...)) and table constructors ({a, b, ...})load()varargs)Scope & Register Management
find_upvalueasensure_upvaluefor correct 3+ level upvalue chainsopen_upvaluesto State struct for proper persistence through loopsgen_blockto prevent register overflowmax_registersuses peaknext_regfrom codegen (not just scope locals)Compiler Fixes
gen_var_by_namefor local table lookups.0,0.,2.E-1, hex float literals now validStandard Library
string.packsizeimplementationtable.unpacknil handlingassertreturns all arguments_ENVsupportTest Status
Breaking Changes
None - all existing tests continue to pass.
🤖 Generated with Claude Code