Qqwy / elixir-type_check

TypeCheck: Fast and flexible runtime type-checking for your Elixir projects.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error: misplaced operator ::/2

zimt28 opened this issue · comments

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?

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.

How could I miss that 🙄 Solved it, thanks!

No worries! 🙂