Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move atom in unquote(atoms) out of the guards #62

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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