Skip to content

fix: preserve call function environments in functors - #2

Merged
gvvaughan merged 1 commit into
lua-stdlib:masterfrom
khaneliman:preserve-callable-environments
Oct 18, 2026
Merged

gvvaughan merged 1 commit into
lua-stdlib:masterfrom
khaneliman:preserve-callable-environments

Conversation

@khaneliman

Copy link
Copy Markdown
Contributor

Prefer a callable table's call function over its __call dispatcher when reading or setting its environment. A shared dispatcher delegates to self.call, so changing the dispatcher's environment leaves the wrapped function unchanged and can affect unrelated tables.

The regression passes on Lua 5.1 through 5.5 and LuaJIT, with argument checking absent, enabled and disabled. The new Specl examples pass on Lua 5.5; nine other failures in the wider environment group reproduce unchanged on the base revision.

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.
@gvvaughan

Copy link
Copy Markdown
Contributor

Merged. Looks good, and helps with my trying to get the master branch of lua-stdlib backwards compatible with the release branch. Thanks for contributing @khaneliman!

@gvvaughan
gvvaughan merged commit 7478a6c into lua-stdlib:master Oct 18, 2026
@khaneliman
khaneliman deleted the preserve-callable-environments branch October 18, 2026 23:34
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