# The pattern ... can never match since previous clauses completely covered the type ...

**URL:** <https://erlangforums.com/t/the-pattern-can-never-match-since-previous-clauses-completely-covered-the-type/2668>\
**Category:** Questions / Help\
**Tags:** dialyzer\
**Created:** [June 7, 2023, 7:58am UTC](https://erlangforums.com/t/the-pattern-can-never-match-since-previous-clauses-completely-covered-the-type/2668 "2023-06-07T07:58:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![p-kraszewski](https://erlangforums.com/user_avatar/erlangforums.com/p-kraszewski/32/1983_2.png) [@p-kraszewski](https://erlangforums.com/u/p-kraszewski)\
**Post date:** [June 7, 2023, 7:58am UTC](https://erlangforums.com/t/the-pattern-can-never-match-since-previous-clauses-completely-covered-the-type/2668/1 "2023-06-07T07:58:55Z")

</div>

Hello fellow Erlangers!

I’m writing quite a beefy Erlang system (I’m not quite a beginner - using Erlang one way or another for over 10 years). Last week `dialyzer` hit me with an unexpected error:

> The pattern \<Packet, OldState\> can never match since previous clauses completely covered the type …

The code it refers to is like that (it is a module-private function):

```erlang
processor(Packet = #{seq := 0}, OldState) ->
    % Body 1
;
processor(Packet = #{seq := Seq}, OldState) ->
    % Body 2
;
processor(Packet, OldState) ->
    % Catch all - report unprocessed
.

```

My question is: in my system _as of now_, `processor/2` is indeed _never_ called without the `seq` field. Is `dialyzer` sophisticated enough to notice there’s no path to supply `Packet` without a `seq` field?

OTOH, I wouldn’t be much surprised after my hunt for all _“… has no local return”_ which all turned either bugs in my code (boo) or `error/1` in NIF stubs instead of the proper `erlang:nif_error/1` (yay - Erlang manual pages should be updated to reflect this change).

---

<div class="post-metadata">

**Author:** ![rfk23](https://erlangforums.com/letter_avatar_proxy/v4/letter/r/77aa72/32.png) [@rfk23](https://erlangforums.com/u/rfk23)\
**Post date:** [June 7, 2023, 8:27am UTC](https://erlangforums.com/t/the-pattern-can-never-match-since-previous-clauses-completely-covered-the-type/2668/2 "2023-06-07T08:27:26Z")

</div>

I am not an expert on dialyzer, but yes, dialyzer performs very sophisticated analysis of the control flow of the program. I assume that `processor` function is not exported. Then from all invocations of this function within the module it can derive that it’s always called with `Packet` argument having a certain type.

---

<div class="post-metadata">

**Author:** ![p-kraszewski](https://erlangforums.com/user_avatar/erlangforums.com/p-kraszewski/32/1983_2.png) [@p-kraszewski](https://erlangforums.com/u/p-kraszewski)\
**Post date:** [June 7, 2023, 8:28am UTC](https://erlangforums.com/t/the-pattern-can-never-match-since-previous-clauses-completely-covered-the-type/2668/3 "2023-06-07T08:28:25Z")

</div>

Replying to self:

- Yes, `dialyzer` _is_ that sophisticated. After making `processor/2` public (so guarantees are off the table) the warning disappears. Wow, just wow.
- I [just reported](https://github.com/erlang/otp/issues/7371) `error/1` in NIF documentation problem.
