Skip to content

debug: preserve call-backed functable environments - #111

Merged
gvvaughan merged 1 commit into
lua-stdlib:releasefrom
khaneliman:fix-release-callable-environments
Oct 18, 2026
Merged

gvvaughan merged 1 commit into
lua-stdlib:releasefrom
khaneliman:fix-release-callable-environments

Conversation

@khaneliman

@khaneliman khaneliman commented Oct 16, 2026 •

Copy link
Copy Markdown

Restore the call field's precedence over a functable's __call dispatcher in the release branch's environment functions. Changing only a shared dispatcher leaves the wrapped function in its old environment; this restores the behavior from before the environment-function backport.

This backports commit 8b877b249c6f2353cae570647a17fc25464d73c5 from lua-stdlib/normalize#2 using git cherry-pick -x, adapting the implementation and regression tests to the release branch's file layout. That canonical PR is still pending. This PR targets the maintained release branch rather than master, which delegates these functions to normalize.

The two added subprocess regression examples fail on the base revision and pass on Lua 5.1 through 5.5 and LuaJIT. Direct environment and module-loading checks also pass on all six. The wider debug specs retain baseline failures, and the complete suite aborts on existing spec-generation errors, so this is not a green full-suite result.

Prefer a functor's call field over its __call dispatcher when reading or
setting its environment. This keeps shared dispatchers unchanged and applies
the environment to the function that executes the wrapped code.

Backport to the maintained stdlib release branch, adapting the implementation
to lib/std/debug.lua and the regression tests to specs/debug_spec.yaml.
Current stdlib master delegates these functions to std.normalize.

(cherry picked from commit 8b877b249c6f2353cae570647a17fc25464d73c5)
@gvvaughan

Copy link
Copy Markdown
Contributor

Thanks again, I'm merging this too, although I'm hoping to put out a backwards compatible lua-stdlib release from the master branch in the next week or so -- as long as I can solve all the annoying little papercuts (like this one!) that have been holding me back for the last few years. Assuming I'm not over-promising here, that release will rely on std.normalize which has your other PR applied, so nothing lost :-)

@gvvaughan
gvvaughan merged commit e9ed787 into lua-stdlib:release Oct 18, 2026
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.

2 participants