Skip to content

feat(phase-17): Vararg expansion, scope fixes, and suite triage#141

Open
davydog187 wants to merge 3 commits intomainfrom
phase-17-vararg-scope
Open

feat(phase-17): Vararg expansion, scope fixes, and suite triage#141
davydog187 wants to merge 3 commits intomainfrom
phase-17-vararg-scope

Conversation

@davydog187
Copy link
Contributor

Summary

Major improvements for Lua 5.3 compliance:

Multi-Return & Vararg Expansion

  • Implement multi-return value expansion across call arguments, table constructors, and return statements
  • Vararg expansion in local/regular multi-assignment (local a, b, c = ...)
  • Vararg support in function calls (f(a, b, ...)) and table constructors ({a, b, ...})
  • Main chunk marked as vararg per Lua 5.3 spec (enables load() varargs)

Scope & Register Management

  • Fix for-loop register allocation: reserve 3 registers for internal counter/limit/step
  • Fix upvalue nesting: rewrite find_upvalue as ensure_upvalue for correct 3+ level upvalue chains
  • Move open_upvalues to State struct for proper persistence through loops
  • Temp register recycling in gen_block to prevent register overflow
  • max_registers uses peak next_reg from codegen (not just scope locals)

Compiler Fixes

  • Floor division/modulo use Lua 5.3 floor semantics
  • FuncDecl dotted names: emit closure instructions, use gen_var_by_name for local table lookups
  • Float literal parsing: .0, 0., 2.E-1, hex float literals now valid
  • Local function redefinition scoping fixes

Standard Library

  • string.packsize implementation
  • table.unpack nil handling
  • assert returns all arguments
  • _ENV support

Test Status

  • Suite tests: 4/29 passing (simple_test.lua, api.lua, code.lua, vararg.lua) - up from 1/29
  • Unit tests: 1,273 passing, 0 failures

Breaking Changes

None - all existing tests continue to pass.

🤖 Generated with Claude Code

Dave Lucia and others added 2 commits February 14, 2026 06:29
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>
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