In this case study, we migrate Padmark — a pure-Elixir Markdown parser and HTML transformer with leex/yecc lexers and parsers (81 BEAM modules) — from Dialyzer (dialyxir) to Prisma.
Running both tools side by side on Elixir 1.20.4 / OTP 29.1.2 highlights two complementary differences: Dialyzer took 1m 18.57s on a cold PLT build (2.13s warm) and reported 0 errors, whereas Prisma completed its cold dependency PPLT build + analysis in 9.76s (0.95s warm) and uncovered 5 real issues — two @spec bugs (one causing dead_code) and three unused private-function parameters (oxbow_code) — plus an upstream Elixir stdlib spec imprecision in Regex.run/2 and Regex.scan/2 that we submitted in elixir-lang/elixir#16151.
1. Execution Metrics & Summary
| Metric |
Dialyzer (dialyxir) |
Prisma (0.2.6 / 0.2.7) |
|---|---|---|
| Padmark BEAM modules | 81 | 81 |
| Elixir / Erlang runtime | Elixir 1.20.4 / OTP 29 (ERTS 17.1.1) | Elixir 1.20.4 / OTP 29 (ERTS 17.1.1) |
| Cold build + check (wall) |
78.57 s (74.17s PLT + 1.50s check) |
9.76 s (17 dep PPLTs + check) |
| Cold CPU (user / sys) |
185.83s / 15.11s (255% CPU) |
9.37s / 2.07s (117% CPU) |
| Warm check (wall) |
2.13 s (1.62s analysis) |
0.95 s (0.45s–0.52s analysis) |
| Warm CPU (user / sys) |
2.68s / 0.76s (161% CPU) |
0.87s / 0.65s (159% CPU) |
| Findings reported | 0 |
10 (5 real + 5 Regex.run/3 spec union) |
Post-fix mix test |
— | 424 passed (59 doctests, 365 tests) |
(Note: dialyxir also pulled in erlex as a transitive dependency; removing dialyxir unlocked both packages from mix.lock and replaced Dialyzer in .check.exs with mix prisma.)
2. What Prisma Caught That Dialyzer Missed
Dialyzer's success typing leaves wide or mismatched @specs silent as long as some execution path can succeed. Prisma's hybrid mode caught 5 genuine issues in Padmark:
A. @spec Mismatches & Dead Code (2)
-
Padmark.Helpers.replace/4(lib/padmark/helpers.ex:7)-
Declared:
@spec replace(String.t(), Regex.t(), String.t() | (... -> String.t()), Padmark.Options.options()) :: String.t() -
Actual:
Padmark.Helpers.replace/4forwardsoptionsstraight toRegex.replace/4, whose spec expectsglobal: boolean()— not%Padmark.Options{}structs or maps. -
Fix: Narrowed the 4th parameter spec to
global: boolean().
-
-
Padmark.Transform.transform/2(lib/padmark/transform.ex:266) —dead_code-
Declared:
@spec transform(Padmark.ast(), Options.options()) :: String.t() -
Actual: The docstring states it "also accepts the result of
map_ast_withfor convenience", and the very first clause isdef transform({ast, _}, options). BecausePadmark.ast()is a list, Prisma flagged that clause as unreachable (Function clause pattern cannot match). -
Fix: Widened the first parameter spec to
Padmark.ast() | {Padmark.ast(), term()}.
-
Declared:
B. Unused Private Parameters (oxbow_code, 3)
-
Padmark.Parser.Ast.Inline.footnote_link/3(lib/padmark_parser/ast/inline.ex:397):_match(argument #2) was ignored across all clauses -> simplified tofootnote_link/2. -
Padmark.Parser.Parser.ListParser._finish_list_item/3(lib/padmark_parser/parser/list_parser.ex:195):_at_start?(argument #2) was ignored and forwarded through_finish_list_items/4-> removed from both helpers. -
Padmark.Transform._make_att1/2(lib/padmark/transform.ex:484):tag(_) (argument #2) was ignored -> simplified to_make_att1/1.
3. From a False Positive in Padmark to an Upstream Elixir PR
The remaining 5 findings in Padmark.Parser.LineScanner (lib/padmark_parser/line_scanner.ex) all came from calling Regex.run/2 (via regex_run(key, target) -> Regex.run(rgx_map(key), target, [])) and then passing the captured groups to String.length/1, String.trim/1, and String.starts_with?/2:
@spec run(t, binary, capture_opts) :: nil | [binary] | [{integer, integer}]
def run(regex, string, options \\ [])
Because Elixir defines Regex.run/2 via a default argument options \\ [], the 2-arity function inherited [{integer, integer}] in its return union — even though Regex.run/2 without return: :index can never return index tuples. Dialyzer stays silent because [binary] overlaps String.t(), whereas Prisma's gradual_mismatch rejects {integer(), integer()} | String.t() where String.t() is expected.
Running Prisma across Elixir's own lib/elixir/ebin (2.68s for the entire standard library) confirmed the same pattern in Regex.run/2 and Regex.scan/2, along with several unused private parameters (Calendar.ISO.zone_to_iodata/4, GenEvent.server_update/5, GenEvent.server_call_update/4, Registry.Partition.init_pid_ets/2, Code.Formatter.unary_op_to_algebra/5, and Code.Fragment.codepoint_cursor_context/2). Those fixes were submitted upstream in elixir-lang/elixir#16151.
4. Engineering Bonus Along the Way
Benchmarking padmark's dependencies and Elixir's standard library during this migration also surfaced two major performance bugs in Prisma itself:
-
Exponential
andalso/orelsere-evaluation (v0.2.5): Building Elixir's 271-module.ppltdropped from 2m 11.98s to 1.95s (~68× faster;Elixir.Calendar.ISOalone dropped from 124s to 15.1ms). -
Infinite recursion in
tuple_combinations/1(v0.2.6): Building the.ppltforerlex 0.2.9(erlex_parser.beam) dropped from a >6-minute hang to 0.25s. -
Community issue sweep (
v0.2.7): All 16 open issues (#1–#16) were verified, resolved, and covered with regression tests (290 EUnit tests, 18/18 PropEr properties passing).