Ex_doc: Callback parameter naming fails

Created on 21 Feb 2019  路  2Comments  路  Source: elixir-lang/ex_doc

Full source: https://github.com/straw-hat-team/straw_hat_twitch/tree/master/lib/straw_hat_twitch/chat

I have the following module

defmodule StrawHat.Twitch.Chat.Message do
  @type t :: %__MODULE__{
          username: String.t(),
          channel_name: String.t(),
          body: String.t()
        }
end

And this other one

defmodule StrawHat.Twitch.Chat.MessageBroker do
  @callback publish(pid, %StrawHat.Twitch.Chat.Message{}) :: no_return
end

When I use %StrawHat.Twitch.Chat.Message{} in StrawHat.Twitch.Chat.MessageBroker it generates the documentation using just %

screen shot 2019-02-20 at 7 49 58 pm

When I change it to StrawHat.Twitch.Chat.Message.t it renames the argument to arg1

I am confused why it is behaving differently when for the most part should be the same.

Elixir Bug

Most helpful comment

As per https://hexdocs.pm/elixir/Kernel.html#defstruct/1-types, it's recommended to use SomeStruct.t over %SomeStruct{} when _referencing_ a struct type, but yeah, it's definitely a bug - thanks for the report.

All 2 comments

As per https://hexdocs.pm/elixir/Kernel.html#defstruct/1-types, it's recommended to use SomeStruct.t over %SomeStruct{} when _referencing_ a struct type, but yeah, it's definitely a bug - thanks for the report.

it's recommended to use SomeStruct.t over %SomeStruct{}

@wojtekmach aye! I am using t since was an accident 馃槃

Was this page helpful?
0 / 5 - 0 ratings