Skip to content

fix: preserve call function environments in functors - #2

Open
khaneliman wants to merge 1 commit into
lua-stdlib:masterfrom
khaneliman:preserve-callable-environments
Open

khaneliman wants to merge 1 commit into
lua-stdlib:masterfrom
khaneliman:preserve-callable-environments

Conversation

@khaneliman

Copy link
Copy Markdown

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.

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