Skip to content

Styler fails on function header without parameters #185

@ypconstante

Description

@ypconstante

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions