# Confusing dialyzer warning

**URL:** <https://forum.elixirforum.com/t/confusing-dialyzer-warning/46128>\
**Category:** Questions\
**Tags:** dialyzer, dialyxir\
**Created:** [February 17, 2022, 9:43pm UTC](https://forum.elixirforum.com/t/confusing-dialyzer-warning/46128 "2022-02-17T21:43:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sax](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sax/32/7405_2.png) [@sax](https://forum.elixirforum.com/u/sax)\
**Post date:** [February 17, 2022, 9:43pm UTC](https://forum.elixirforum.com/t/confusing-dialyzer-warning/46128/1 "2022-02-17T21:43:50Z")

</div>

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.

```elixir
lib/dyd.ex:101:pattern_match
The pattern can never match the type.

Pattern:
{:error, {:invalid_toml, _error}}

Type:
{:error, :invalid_time_unit | :not_a_datetime}

```

Here is the offending line, pinned to a specific commit:  
[https://github.com/geometerio/dyd/blob/fee50b18962f0f63dfbe411b242c8c5a87f47dd7/lib/dyd.ex#L101](https://github.com/geometerio/dyd/blob/fee50b18962f0f63dfbe411b242c8c5a87f47dd7/lib/dyd.ex#L101)

Here is the second usage, which does not generate any warnings:  
[https://github.com/geometerio/dyd/blob/fee50b18962f0f63dfbe411b242c8c5a87f47dd7/lib/dyd.ex#L136](https://github.com/geometerio/dyd/blob/fee50b18962f0f63dfbe411b242c8c5a87f47dd7/lib/dyd.ex#L136)

Here is the spec that should make the statement valid:  
[https://github.com/geometerio/dyd/blob/fee50b18962f0f63dfbe411b242c8c5a87f47dd7/lib/dyd/manifest.ex#L41](https://github.com/geometerio/dyd/blob/fee50b18962f0f63dfbe411b242c8c5a87f47dd7/lib/dyd/manifest.ex#L41)

This is with the following versions:

- OTP: 24.2.1
- Elixir: 1.13.3
- Dialyxir: 1.1.0

---

<div class="post-metadata">

**Author:** ![al2o3cr](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/al2o3cr/32/3457_2.png) [@al2o3cr](https://forum.elixirforum.com/u/al2o3cr)\
**Post date:** [February 17, 2022, 11:25pm UTC](https://forum.elixirforum.com/t/confusing-dialyzer-warning/46128/2 "2022-02-17T23:25:17Z")

</div>

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

[https://github.com/elixir-lang/elixir/issues/10385](https://github.com/elixir-lang/elixir/issues/10385)

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

[https://github.com/elixir-lang/elixir/issues/7177](https://github.com/elixir-lang/elixir/issues/7177)

---

<div class="post-metadata">

**Author:** ![sax](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sax/32/7405_2.png) [@sax](https://forum.elixirforum.com/u/sax)\
**Post date:** [February 18, 2022, 4:52pm UTC](https://forum.elixirforum.com/t/confusing-dialyzer-warning/46128/3 "2022-02-18T16:52:42Z")

</div>

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.
