Skip to content

Commit eb4e546

Browse files
committed
fix crash when unable to get stackframe arity
1 parent c2338b7 commit eb4e546

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

apps/elixir_ls_debugger/lib/debugger/stacktrace.ex

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ defmodule ElixirLS.Debugger.Stacktrace do
2121

2222
def name(%__MODULE__{function: function} = frame) when not is_nil(function) do
2323
{f, a} = frame.function
24-
"#{inspect(frame.module)}.#{f}/#{a}"
24+
25+
case a do
26+
:undefined -> "#{inspect(frame.module)}.#{f}/?"
27+
_ -> "#{inspect(frame.module)}.#{f}/#{a}"
28+
end
2529
end
2630

2731
def name(%__MODULE__{} = frame) do
@@ -40,7 +44,7 @@ defmodule ElixirLS.Debugger.Stacktrace do
4044
first_frame = %Frame{
4145
level: level,
4246
module: module,
43-
function: {function, Enum.count(args)},
47+
function: {function, get_arity(args)},
4448
args: args,
4549
file: get_file(module),
4650
# vscode raises invalid request when line is nil
@@ -62,7 +66,7 @@ defmodule ElixirLS.Debugger.Stacktrace do
6266
%Frame{
6367
level: level,
6468
module: mod,
65-
function: {function, Enum.count(args)},
69+
function: {function, get_arity(args)},
6670
args: args,
6771
file: get_file(mod),
6872
# vscode raises invalid request when line is nil
@@ -107,4 +111,7 @@ defmodule ElixirLS.Debugger.Stacktrace do
107111
def get_file(module) do
108112
Path.expand(to_string(ModuleInfoCache.get(module)[:compile][:source]))
109113
end
114+
115+
defp get_arity(:undefined), do: :undefined
116+
defp get_arity(args), do: Enum.count(args)
110117
end

0 commit comments

Comments
 (0)