Skip to content

fix: correct stack value handling for nil, multi-returns, and NUL bytes - #47

Merged
veelenga merged 3 commits into
masterfrom
fix/stack-value-handling
Aug 9, 2026
Merged

fix: correct stack value handling for nil, multi-returns, and NUL bytes#47
veelenga merged 3 commits into
masterfrom
fix/stack-value-handling

Conversation

@veelenga

@veelenga veelenga commented Aug 9, 2026

Copy link
Copy Markdown
Owner

Overview

Fixes three pre-existing bugs found during the review of #45:

  • Stack#pop now removes nil values instead of leaving them on the stack, which corrupted results and leaked stack slots (run(%q( return 5, nil )) returned [nil, nil] and left a dirty stack)
  • pick_results reads values by index instead of popping, so multiple return values keep their order (return 1, 2 returned [2.0, 1.0]); coroutine resume now locates results via the nres out-param of lua_resume
  • strings with embedded zero bytes survive both directions: reads use tolstring's length out-param and pushes use pushlstring with bytesize (previously truncated at the first \0)

Each fix comes with regression specs.

@veelenga veelenga self-assigned this Aug 9, 2026
@veelenga
veelenga merged commit c5e3e09 into master Aug 9, 2026
1 check passed
@veelenga
veelenga deleted the fix/stack-value-handling branch August 9, 2026 12:58
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