Skip to content

debug: preserve call-backed functable environments - #111

Open
khaneliman wants to merge 1 commit into
lua-stdlib:releasefrom
khaneliman:fix-release-callable-environments
Open

khaneliman wants to merge 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)

This branch has not been deployed

No deployments
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