adobe/elixir-styler

Styler fails on function header without parameters

Closed this issue · 1 comments

Styler fails to get the line ending for a function header without parameters.
In my code I'm using using this function header because the behavior callback implementation will be added on @before_compile, and to avoid a compilation warning I have to add this function header.

Versions

  • Elixir: Elixir 1.16.2 (compiled with Erlang/OTP 26)
  • Styler: 1.0.0-rc.2

Example Input

defmodule Example do
  @callback list() :: any()

  defmacro __using__(_) do
    quote do
      @behaviour Example

      @impl Example
      def list
    end
  end
end

Stacktrace / Current Behaviour

** (Styler.StyleError) Error running style Defs on lib/example.ex
   Please consider opening an issue at: https://github.com/adobe/elixir-styler/issues/new
** (ArgumentError) ranges (first..last) expect both sides to be integers, got: 9..nil

    (elixir 1.16.2) lib/range.ex:193: Range.new/2
    (styler 1.0.0-rc.2) lib/style/defs.ex:59: Styler.Style.Defs.run/2
    (styler 1.0.0-rc.2) lib/zipper.ex:386: Styler.Zipper.do_traverse_while/3
    (styler 1.0.0-rc.2) lib/styler.ex:42: anonymous fn/4 in Styler.style/3
    (elixir 1.16.2) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3
    (styler 1.0.0-rc.2) lib/styler.ex:38: Styler.style/3
    (styler 1.0.0-rc.2) lib/styler.ex:72: Styler.format/2
    (elixir 1.16.2) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3

thanks for the report =)