When implementing NIFs, Dialyzer gives me
Function crc16/1 has no local return
probably because I do exit in the .erl module (like the official docs recommend):
-module(my_nifs).
-export([crc16/1]).
-on_load(init/0).
init() ->
ok = erlang:load_nif("../nifs/my_nifs", 0).
-spec crc16(_Binary :: binary()) -> non_neg_integer().
crc16(_Binary) ->
exit(nif_library_not_loaded).
...
And generally, it seems that using exit/1
always makes Dialyzer to complain with this message (-spec .. -> no_return()
doesn't help).
How can this be fixed?
You could use erlang:nif_error/1/2
which where created just for that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With