Skip to content

Conversation

velimir
Copy link

@velimir velimir commented Jun 7, 2023

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?

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant