I ran mix format I am expecting this line https://github.com/straw-hat-team/straw_hat_mailer/blob/224410cf37ee685237bc058c4822361e6b705f4d/lib/straw_hat_mailer/schema/template.ex#L76 do not change
I am expecting the typespec to be added the parenthesis as Elixir does with the primitive types (so far).
So it would change to
@spec changeset(t(), partial_attrs()) :: Ecto.Changeset.t()
Elixir formatter cannot change the AST/semantics of the code, otherwise we risk breaking the code. For this reason, we only add parens to remote calls, we cannot add to variables.
I know from context you know it is a spec but the formatter does not have such context.
@josevalim if that is true why does the formatter add the parenthesis when I remove it from Ecto.Changeset.t what does we only add parens to remote calls means? For my personal knowledge, if you dont mind to answer.
With Ecto.Changeset.t we know it has to be a function call so we can add the parenthesis. For t it can be either a function call or a variable so we could break code if parenthesis are added.
Parens can't be added there because as it's written now, that t could be a reference to either a function _or_ a variable in that scope. Adding parens could break if it was supposed to be a reference to a variable.
If something is a function call outside of the current scope, you can be sure that it's not a reference to a variable, so you can safely add the parens.
Most helpful comment
Parens can't be added there because as it's written now, that
tcould be a reference to either a function _or_ a variable in that scope. Adding parens could break if it was supposed to be a reference to a variable.If something is a function call outside of the current scope, you can be sure that it's not a reference to a variable, so you can safely add the parens.