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

Styler dont work when macro is piped #91

Closed
NikitaNaumenko opened this issue Dec 1, 2023 · 1 comment
Closed

Styler dont work when macro is piped #91

NikitaNaumenko opened this issue Dec 1, 2023 · 1 comment

Comments

@NikitaNaumenko
Copy link

First of all thanks for that project and your work.

Styler dont work when macros piped, it raises error when try to format piped macros

Versions

  • Elixir:
    Erlang/OTP 26 [erts-14.0.2] [source] [64-bit] [smp:10:10] [ds:10:10:10] [async-threads:1] [jit]

Elixir 1.14.5 (compiled with Erlang/OTP 26)`

  • Styler: locked at 0.10.2 (styler) b32766d9`

Example Input

  defmacro tx(do: block) do
    quote location: :keep, generated: true do
      unquote(__MODULE__).transaction(fn ->
        case unquote(block) do
          {:error, err} -> unquote(__MODULE__).rollback(err)
          {:ok, result} -> result
          result -> result
        end
      end)
    end
  end
  
   result =
      Ubr.Repo.tx do
        .... some_code
      end
    |> case do
      {:ok, %{verified: true}} -> :ok
      _ -> {:error, :invalid_code}
    end```

## Stacktrace / Current Behaviour
`** (Styler.StyleError) Error running style Pipes on lib/ubr/accounts/use_cases/verify_two_step_auth_attempt.ex
   Please consider opening an issue at: https://github.com/adobe/elixir-styler/issues/new
** (Protocol.UndefinedError) protocol String.Chars not implemented for {:., [line: 24], [{:__aliases__, [last: [line: 24], line: 24], [:Ubr, :Repo]}, :tx]} of type Tuple

    (elixir 1.14.5) lib/string/chars.ex:3: String.Chars.impl_for!/1
    (elixir 1.14.5) lib/string/chars.ex:22: String.Chars.to_string/1
    lib/style/pipes.ex:106: Styler.Style.Pipes.extract_start/1
    lib/style/pipes.ex:64: Styler.Style.Pipes.fix_pipe_start/1
    lib/style/pipes.ex:33: Styler.Style.Pipes.run/2
    lib/zipper.ex:345: Styler.Zipper.do_traverse_while/3
    lib/styler.ex:37: anonymous fn/4 in Styler.style/3
    (elixir 1.14.5) lib/enum.ex:2468: Enum."-reduce/3-lists^foldl/2-0-"/3`
@novaugust
Copy link
Contributor

thanks for the issue! (and the kind words 😄 )
fixed in 0.10.3 =)

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

No branches or pull requests

2 participants