Error: misplaced operator ::/2
zimt28 opened this issue · comments
zimt28 commented
The module below does not compile but throws an error:
** (CompileError) .../account.ex:12: misplaced operator ::/2
(the @type!
)
Same error for the @spec!
when I comment the @type!
.
defmodule App.Accounts.Account
use Ecto.Schema
import Ecto.Changeset
alias App.Accounts.Account
@primary_key {:id, :binary_id, autogenerate: true}
@foreign_key_type :binary_id
@timestamps_opts [type: :utc_datetime_usec]
@type! t :: %Account{
title: binary()
}
schema "accounts" do
field :title, :string
timestamps()
end
@doc false
@spec! changeset(account :: t(), attrs :: map()) :: %Ecto.Changeset{}
def changeset(%Account{} = account, attrs) do
account
|> cast(attrs, [:title])
|> validate_required([:title])
end
end
Similar code has worked before, so what am I doing wrong here?
Qqwy / Marten commented
It seems like you're not calling use TypeCheck
, which means that Elixir will complain about ::
being used in any places outside of 'normal' @type
and @spec
attributes.
zimt28 commented
How could I miss that 🙄 Solved it, thanks!
Qqwy / Marten commented
No worries! 🙂