Skip to content

Commit 05c9cca

Browse files
committed
Check for stacktrace at compile-time and runtime
1 parent 7533e56 commit 05c9cca

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/elixir/lib/system.ex

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,9 +600,17 @@ defmodule System do
600600
"""
601601
# TODO: Once Erlang/OTP 23 is required, remove conditional, and update @doc accordingly.
602602
# The warning is emitted by the compiler - so a @doc annotation is enough
603+
# Note Elixir may be compiled in an earlier Erlang version but runs on a
604+
# newer one, so we need the check at compilation time and runtime.
603605
@doc deprecated: "Use __STACKTRACE__ instead"
604606
if function_exported?(:erlang, :get_stacktrace, 0) do
605-
def stacktrace, do: apply(:erlang, :get_stacktrace, [])
607+
def stacktrace do
608+
if function_exported?(:erlang, :get_stacktrace, 0) do
609+
apply(:erlang, :get_stacktrace, [])
610+
else
611+
[]
612+
end
613+
end
606614
else
607615
def stacktrace, do: []
608616
end

0 commit comments

Comments
 (0)