Skip to content

Commit d027555

Browse files
author
José Valim
committed
Revert "Attempt to soft_purge modules, closes #7047"
Soft purging modules was badfun/badarg errors when invoking left over anonymous functions.
1 parent 2ab2bff commit d027555

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

lib/elixir/src/elixir_compiler.erl

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,19 @@ compile(Forms, Vars, #{line := Line, file := File} = E) ->
7676

7777
{Module, Binary} = elixir_erl_compiler:noenv_forms(Form, File, [nowarn_nomatch]),
7878
code:load_binary(Module, "", Binary),
79-
dispatch(Module, Fun, Args, I, EE).
8079

81-
dispatch(Module, Fun, Args, I, E) ->
80+
Purgeable = beam_lib:chunks(Binary, [labeled_locals]) ==
81+
{ok, {Module, [{labeled_locals, []}]}},
82+
dispatch(Module, Fun, Args, Purgeable, I, EE).
83+
84+
dispatch(Module, Fun, Args, Purgeable, I, E) ->
8285
Res = Module:Fun(Args),
8386
code:delete(Module),
84-
case code:soft_purge(Module) of
85-
true -> return_compiler_module(I);
86-
false -> ok
87+
if Purgeable ->
88+
code:purge(Module),
89+
return_compiler_module(I);
90+
true ->
91+
ok
8792
end,
8893
{Res, E}.
8994

0 commit comments

Comments
 (0)