safwank / ElixirRetry

Simple Elixir macros for linear retry, exponential backoff and wait with composable delays
Other
441 stars 32 forks source link

Add `generated: true` to macro to prevent Dialyzer errors #41

Closed danadaldos closed 2 years ago

danadaldos commented 3 years ago

I am running into issues locally when trying to use retry and Dialyzer together.

When matching on tagged {:error, msg} tuples, I get a Dialyzer error that the pattern can never match :error, and if I match on an :error atom, I get a Dialyzer error that it can never match a tuple {_, _}. If I match on both:

lib/joydrive_web/services/oem_incentive_manager.ex:113:pattern_match
The pattern can never match the type.

Pattern:
:error

Type:
{_, _}

________________________________________________________________________________
lib/joydrive_web/services/oem_incentive_manager.ex:114:pattern_match
The pattern can never match the type.

Pattern:
{:error, _error}

Type:
:error

Passing the following into the macro makes no difference:

retry with: [2], atoms: [:error] do

I propose adding generated: true to the macro to keep Dialyzer from complaining.

safwank commented 3 years ago

Thanks for the PR @danadaldos. We've had a few Dialyzer issues previously, so I'm thinking of finally adding type specs to the library and will consider your PR as part of that.

danadaldos commented 2 years ago

:pray: