Skip to content

Commit

Permalink
Allow tref to pass through encode/2
Browse files Browse the repository at this point in the history
There are times when a `tref` may be passed to Erlang/Elixir, and then
we want to return it as-is (or modified) to the emulator. Currently,
this will fail when Luerl tries to re-encode the value.

Instead, we should just pass through these values as is
  • Loading branch information
davydog187 committed Sep 26, 2024
1 parent c090d4d commit f04f487
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/luerl_new.erl
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,12 @@ encode({M,F,A}, St) when is_atom(M) and is_atom(F) ->
{#erl_mfa{m=M,f=F,a=A}, St};
encode({userdata,Data}, St) ->
luerl_heap:alloc_userdata(Data, St);
% Table refs should not be re-encoded
encode(#tref{}=T, St) ->
{T, St};
encode(_, _) -> error(badarg). %Can't encode anything else


%% decode_list([LuerlTerm], State) -> [Term].
%% decode(LuerlTerm, State) -> Term.
%% In decode we track of which tables we have seen to detect
Expand Down

0 comments on commit f04f487

Please sign in to comment.