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):
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).