Skip to content

Fix crash when suggest_contracts is called without a PLT - #1284

Merged
lukaszsamson merged 1 commit into
masterfrom
fix-suggest-contracts-without-plt
Oct 18, 2026
Merged

lukaszsamson merged 1 commit into
masterfrom
fix-suggest-contracts-without-plt

Conversation

@lukaszsamson

Copy link
Copy Markdown
Collaborator

Problem

Crash report:

** (FunctionClauseError) no function clause matching in ElixirLS.LanguageServer.DialyzerIncremental.handle_call/3
  language_server/dialyzer_incremental.ex:112: ElixirLS.LanguageServer.DialyzerIncremental.handle_call({:suggest_contracts, ["/path/to/file.ex"]}, {#PID<...>, #Reference<...>}, %ElixirLS.LanguageServer.DialyzerIncremental{parent: #PID<0.231.0>, root_path: "...", analysis_pid: nil, warn_opts: [], warning_format: "dialyxir_long", apps_paths: %{ordi_fox: ""}, project_dir: "...", next_build: nil, plt: nil})

DialyzerIncremental.handle_call({:suggest_contracts, files}, ...) only had a clause guarded by plt != nil. A freshly (re)started process has plt: nil while the initial analysis runs, so the call crashed the GenServer and the waiting request never got a reply.

Fix

  • Add a fallback handle_call({:suggest_contracts, _files}, _from, state) clause that replies [] when there is no PLT.
  • DialyzerIncremental.suggest_contracts/2 already catches exits (for example :noproc) and returns [], so the spawned Server processes still reply to waiting clients. No change there.

Tests

  • handle_call/3 with plt: nil replies {:reply, [], state}.
  • suggest_contracts/2 returns [] when no DialyzerIncremental process is running for the parent.

… PLT

DialyzerIncremental.handle_call/3 only matched {:suggest_contracts, files}
when plt != nil. A freshly (re)started process has plt: nil while the
initial analysis is running, so the call crashed the GenServer with a
FunctionClauseError and the waiting request never got a reply.

Add a fallback clause that replies with an empty list, and cover it with
tests for handle_call/3 with plt: nil and for suggest_contracts/2 when no
DialyzerIncremental process is running.
@lukaszsamson
lukaszsamson merged commit 00870d2 into master Oct 18, 2026
23 checks passed
@lukaszsamson
lukaszsamson deleted the fix-suggest-contracts-without-plt branch October 18, 2026 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant