dialyzer: catch parse errors raised from the try/of body in start/1 - #11679
Open
kikofernandez wants to merge 2 commits into
Open
kikofernandez wants to merge 2 commits into
kikofernandez wants to merge 2 commits into
Conversation
dialyzer_cl_parse:start/0 wrapped argparse:parse/3 in a `try ... of ... catch ...`. A try/of only runs its catch clauses over the guarded expression, not over the `of` body. postprocess_side_effects/1 and dialyzer_options:build/1 ran in the `of` body, so throws raised there escaped the catch:
- the `-pa` clause calls `cl_error/1`, which throws `{dialyzer_cl_parse_error, _};` and
- `dialyzer_options:check_output_plt/1` throws `{dialyzer_error, _}`.
Both escaped as `{nocatch, ...}` past the plain case in `dialyzer:plain_cl/0`, crashing the CLI with an Erlang stack trace and a non-standard exit status instead of the documented graceful "dialyzer: <msg>" + exit code. A common typo error (e.g. `-pa` on a non-existent directory) hit this path.
Move the `case` expression inside the `try` body so the of-body is covered by the `catch`, and add a `throw:{dialyzer_error, Msg}` clause for the `check_output_plt` path. Split `start/0` into a thin wrapper over `start/1` (which takes the argument list) so the parsing path is testable without spawning a node; `start/1` is exported but marked `-doc false` as it is not part of the public API.
Add `dialyzer_cl_SUITE:bad_pa_dir_returns_error/1`, which drives `start/1` with a non-existent `-pa` directory and asserts a clean `{error, _}` return.
Contributor
CT Test Results 2 files 42 suites 15m 57s ⏱️ Results for commit 63d9cfe. ♻️ This comment has been updated with latest results. To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass. See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally. Artifacts
// Erlang/OTP Github Action Bot |
garazdawi
previously approved these changes
Sep 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
dialyzer_cl_parse:start/0wrappedargparse:parse/3in atry ... of ... catch .... A try/of only runs its catch clauses over the guarded expression, not over the ofbody. postprocess_side_effects/1anddialyzer_options:build/1ran in theofbody, so throws raised there escaped the catch:-paclause callscl_error/1, which throws{dialyzer_cl_parse_error, _};anddialyzer_options:check_output_plt/1throws{dialyzer_error, _}.Both escaped as
{nocatch, ...}past the plain case indialyzer:plain_cl/0, crashing the CLI with an Erlang stack trace and a non-standard exit status instead of the documented graceful "dialyzer: " + exit code. A common typo error (e.g.-paon a non-existent directory) hit this path.Move the
caseexpression inside thetrybody so the of-body is covered by thecatch, and add athrow:{dialyzer_error, Msg}clause for thecheck_output_pltpath. Splitstart/0into a thin wrapper overstart/1(which takes the argument list) so the parsing path is testable without spawning a node;start/1is exported but marked-doc falseas it is not part of the public API.Add
dialyzer_cl_SUITE:bad_pa_dir_returns_error/1, which drivesstart/1with a non-existent-padirectory and asserts a clean{error, _}return.