Elixir dialyzer warnings failing the build in CI
Dialyzer performed success-typing analysis and reported warnings that the CI step treats as failures - discrepancies between typespecs and actual code, or unreachable clauses.
What this error means
The dialyzer step exits non-zero listing warnings (no_return, pattern_match, contract violations) with file and line. It is deterministic given the code and specs, though PLT issues can vary.
lib/app.ex:14:no_return
Function run/0 has no local return.
lib/app.ex:20:pattern_match
The pattern {:ok, _} can never match the type {:error, _}.Common causes
Typespec and implementation disagree
A @spec says one thing while the code returns another, so Dialyzer reports a contract or no_return discrepancy.
Unreachable or impossible pattern
A clause can never match given the inferred success typing, so Dialyzer flags dead code.
Stale or missing PLT
The persistent lookup table is out of date or not built for the current OTP/deps, producing spurious warnings.
How to fix it
Fix specs and unreachable patterns
- Align each @spec with what the function actually returns.
- Remove or correct clauses Dialyzer marks unreachable.
- Annotate intentional no_return functions appropriately.
Rebuild and cache the PLT
Build the PLT for the current OTP and deps, and cache it keyed on those versions.
mix dialyzer --plt
mix dialyzerHow to prevent it
- Keep @spec annotations in sync with code.
- Cache the PLT keyed on OTP and deps versions.
- Run dialyzer locally before pushing.