-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix callbacks not modifying Luerl state
Callbacks passed to functions implemented in Erlang as `erl_func` in the likes were not updating state correctly. For example, imagine the following Lua program ```lua globalVar = { a = 1 } function modify_global() globalVar['b'] = 2 end external_call(modify_global) return globalVar ``` `external_call` is a function implemented in Erlang as ```erlang ExternalFun = fun([Fun], S) -> {FunRef, NewState1} = luerl_new:encode(Fun, S), io:format("Function ref: ~p~n", [FunRef]), {ok, Res, NewState2} = luerl_new:call(FunRef, [], NewState1), {Res, NewState2} end, State = luerl_new:init(), {ok, [], State1} = luerl_new:set_table_keys_dec([<<"external_call">>], ExternalFun, State), ``` This program returns ```erlang % Expected [[{<<"a">>, 1}, {<<"b">>, 2}]] % Actual [[{<<"a">>, 1}}]] ``` - [X] Write a test case that reproduces the problem - [ ] Fix the root cause
- Loading branch information
1 parent
37991d1
commit 95d3f67
Showing
3 changed files
with
30 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters