ElixirRetry icon indicating copy to clipboard operation
ElixirRetry copied to clipboard

move `atom in unquote(atoms)` out of the guards

Open velimir opened this issue 1 year ago • 0 comments

Problem

def call(service, atoms \\ [:retry_error], rescue_only \\ [], fun) do
  retry with: delay_stream(service),
              rescue_only: rescue_only,
              atoms: atoms do
    # ... fun.()
  after
    result ->
      result
  else
    error ->
      error
  end
end

This code does not comply as when Elixir tries to expand the macro the expanded code refers to "atoms" variable which can not be used in a "in" expression used in a guard.

** (ArgumentError) invalid right argument for operator "in", it expects a compile-time proper list or compile-time range on the right side when used in guard expressions, got: atoms

Solution

Remove "in" expression from the guards to allow the atoms to be a variable.

@safwank What do you think?

velimir avatar Jun 07 '23 15:06 velimir