missing coma on a with block cause styling error
DavidB59 opened this issue · 2 comments
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
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
cheers david, now you'll get less ugly feedback should you ever forget that comma again :)