massivefermion / erl_argon2

nifs for hashing and verifying passwords using argon2
https://hex.pm/packages/argon2
Apache License 2.0
0 stars 0 forks source link

'No local return' dialyzer warnings #1

Open shelvick opened 9 months ago

shelvick commented 9 months ago

Calling argon2:hash/1 or argon2:verify/2 (and possibly others) causes "has no local return" warnings in the dialyzer for the calling code, on Erlang 26. Are these fixable?

massivefermion commented 9 months ago

Honestly, I'm not sure. The problem is that those functions have Erlang implementations that call the following function:

not_loaded(Line) ->
    exit({not_loaded, [{module, ?MODULE}, {line, Line}]}).

This is done so that if, for any reason, the nifs are not loaded, calling them would produce an error message and crash. Not sure what I can do other than this!

Although, maybe adding typing information would help but I haven't really worked with dialyzer before and I'm having trouble even setting it up. I'd appreciate a PR if you're up to it.

shelvick commented 9 months ago

I would've submitted one already if I knew how to fix it. :sweat_smile: Normally, to run dialyzer you just switch to the project root and do rebar3 dialyzer. However in this case compiling from the git repo didn't work for me:

cp: cannot stat 'target/release/liberl_argon2.so': No such file or directory

Not sure if that's another bug or just my machine. Anyway, it does look like there's a way to suppress warnings for a single function: https://www.erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files Not the ideal fix of course, but again, I don't know what the ideal fix looks like.