Skip to content

Commit 51db16b

Browse files
committed
do not crash if optional callback cannot be found
1 parent 73d9b0c commit 51db16b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/elixir_sense/core/compiler/state.ex

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -489,10 +489,14 @@ defmodule ElixirSense.Core.Compiler.State do
489489
updated_specs =
490490
list
491491
|> Enum.reduce(state.specs, fn {fun, arity}, acc ->
492-
acc
493-
|> Map.update!({module, fun, arity}, fn spec_info = %SpecInfo{} ->
494-
%{spec_info | meta: spec_info.meta |> Map.put(:optional, true)}
495-
end)
492+
case acc[{module, fun, arity}] do
493+
nil ->
494+
acc
495+
496+
spec_info = %SpecInfo{} ->
497+
spec_info = %{spec_info | meta: spec_info.meta |> Map.put(:optional, true)}
498+
Map.put(acc, {module, fun, arity}, spec_info)
499+
end
496500
end)
497501

498502
%{state | specs: updated_specs}

0 commit comments

Comments
 (0)