Confusing dialyzer warning

Every time I run into an issue with dialyzer, it’s my fault. I respect that, and predict that it’s also the case here. I’m stumped with this one, though.

I’m using a with statement that may return two different matches. I use this same with statement twice. In one of the statements, dialyzer only sees the return values from one of the function calls.

If anyone has some spare moments to take a look at the code, I’d appreciate any pointers.

The pattern can never match the type.

{:error, {:invalid_toml, _error}}

{:error, :invalid_time_unit | :not_a_datetime}

Here is the offending line, pinned to a specific commit:

Here is the second usage, which does not generate any warnings:

Here is the spec that should make the statement valid:

This is with the following versions:

  • OTP: 24.2.1
  • Elixir: 1.13.3
  • Dialyxir: 1.1.0
1 Like

This may not be the same underlying issue, but the situation (else clauses with no_return in each fail type analysis) sounds really similar:

or this (also linked to the same open issue):

1 Like

Cool, thanks for the links! That gives me some ideas for how I could rewrite this to avoid the condition. Fortunately it’s a CLI app rather than a library, so I can let it sit for a little while.