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

missing coma on a with block cause styling error #158

Closed
DavidB59 opened this issue Apr 19, 2024 · 2 comments
Closed

missing coma on a with block cause styling error #158

DavidB59 opened this issue Apr 19, 2024 · 2 comments

Comments

@DavidB59
Copy link

DavidB59 commented Apr 19, 2024

I was missing a coma after my first function in the with block, and when running mix format I got a styler error.

Versions

  • Elixir: Elixir 1.16.1 (compiled with Erlang/OTP 24)
  • Styler: locked at 0.11.9 (styler) 8b7806ba

Example Input

defmodule StylerIssue do
  @moduledoc false
  def example_input(app_id, identifier) do
    with {:ok, _} <- function_one(app_id, identifier)

    {:ok, _} <-
      function_two(app_id, identifier) do
        :ok
      end
  end
end

Stacktrace / Current Behaviour

** (MatchError) no match of right hand side value: [{:<-, [line: 4], [{:block, [closing: [line: 4], line: 4], [{{:block, [line: 4], [:ok]}, {:_, [line: 4], nil}}]}, {:function_one, [closing: [line: 4], line: 4], [{:app_id, [line: 4], nil}, {:identifier, [line: 4], nil}]}]}]

(styler 0.11.9) lib/style/blocks.ex:81: Styler.Style.Blocks.run/2
(styler 0.11.9) lib/zipper.ex:368: Styler.Zipper.do_traverse_while/3
(styler 0.11.9) lib/styler.ex:38: anonymous fn/4 in Styler.style/3
(elixir 1.16.1) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3
(styler 0.11.9) lib/styler.ex:36: Styler.style/3
(styler 0.11.9) lib/styler.ex:66: Styler.format/3
(elixir 1.16.1) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3
(mix 1.16.1) lib/mix/tasks/format.ex:628: Mix.Tasks.Format.format_file/2

Skipping style and continuing on

@DavidB59 DavidB59 changed the title missing coma on a with block cause styiling error missing coma on a with block cause styling error Apr 19, 2024
@novaugust
Copy link
Contributor

thanks for the report david. i'd like to say it's a bug of mix format's to run on this code since it isn't valid elixir but what do i know? i suppose if someone defined their own with macro to work like a case statement it could be vaild.

i don't really want to update styler to handle code that can't compile, so the best thing i could do here would be to get a better exception raised or just skip over.. i'll see what i can make happen

@novaugust
Copy link
Contributor

cheers david, now you'll get less ugly feedback should you ever forget that comma again :)

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