Skip to content

Commit a7ae832

Browse files
committed
fix a rare crash in dialyzer
1 parent bb09876 commit a7ae832

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

apps/language_server/lib/language_server/dialyzer.ex

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -451,9 +451,14 @@ defmodule ElixirLS.LanguageServer.Dialyzer do
451451
# info may not be available is when it has been stripped by the beam_lib
452452
# module, but that shouldn't be the case. More info:
453453
# http://erlang.org/doc/reference_manual/modules.html#module_info-0-and-module_info-1-functions
454-
module.module_info(:compile)
455-
|> Keyword.get(:source, fallback)
456-
|> Path.relative_to_cwd()
454+
if Code.ensure_loaded?(module) do
455+
module.module_info(:compile)
456+
|> Keyword.get(:source, fallback)
457+
|> Path.relative_to_cwd()
458+
else
459+
# In case the file fails to load return fallback
460+
Path.relative_to_cwd(fallback)
461+
end
457462
end
458463

459464
defp dependent_modules(modules, mod_deps, result \\ MapSet.new())

0 commit comments

Comments
 (0)