Skip to content

Commit 5a1fa35

Browse files
authored
Fix invalid module reference in prune_stacktrace (#15272)
Closes #15271
1 parent 20cd669 commit 5a1fa35

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

lib/elixir/src/elixir_dispatch.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ prune_stacktrace([{_, _, [Caller | _], _} | _], _MFA, Info, {ok, Caller}) ->
349349
prune_stacktrace([{M, F, A, _} | _], {M, F, A}, Info, _E) ->
350350
Info;
351351
%% We've reached the elixir_dispatch internals, skip it with the rest
352-
prune_stacktrace([{Mod, _, _, _} | _], _MFA, Info, _E) when Mod == elixir_dispatch; Mod == elixir_exp ->
352+
prune_stacktrace([{Mod, _, _, _} | _], _MFA, Info, _E) when Mod == elixir_dispatch; Mod == elixir_expand ->
353353
Info;
354354
prune_stacktrace([H | T], MFA, Info, E) ->
355355
[H | prune_stacktrace(T, MFA, Info, E)];

lib/elixir/test/elixir/code_test.exs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,30 @@ defmodule CodeTest do
215215
end
216216
end
217217

218+
test "prunes elixir_expand from macro expansion stacktraces" do
219+
defmodule PruneStacktraceMacro do
220+
defmacro bad do
221+
quote do
222+
receive 1
223+
end
224+
end
225+
end
226+
227+
stacktrace =
228+
try do
229+
Code.eval_quoted(
230+
quote do
231+
require PruneStacktraceMacro
232+
PruneStacktraceMacro.bad()
233+
end
234+
)
235+
rescue
236+
CompileError -> __STACKTRACE__
237+
end
238+
239+
refute Enum.any?(stacktrace, &match?({:elixir_expand, :expand, 3, _}, &1))
240+
end
241+
218242
test "warns when lexical tracker process is dead" do
219243
{pid, ref} = spawn_monitor(fn -> :ok end)
220244
assert_receive {:DOWN, ^ref, _, _, _}

0 commit comments

Comments
 (0)