I have this bit of code that’s currently erroring at the _
match:
projects
|> Projects.create_many_notify(socket.assigns.study.id)
|> case do
{:error, changeset} ->
changeset.errors
_ ->
nil
end
The function returns a type of changeset result ({:ok, [struct]} | {:error, changeset}
). The full error message is:
The variable _ can never match since previous clauses completely covered the type
{'error',
#{'__struct__' := 'Elixir.Ecto.Changeset',
'action' := atom(),
'changes' := #{atom() => _},
'constraints' :=
[#{'constraint' := binary(),
'error_message' := binary(),
'error_type' := atom(),
'field' := atom(),
'match' := 'exact' | 'prefix' | 'suffix',
'type' :=
'check' | 'exclusion' | 'foreign_key' | 'unique'}],
'data' := 'nil' | map(),
'empty_values' := _,
'errors' := [{atom(), {binary(), [{atom(), _}]}}],
'filters' := #{atom() => _},
'params' := 'nil' | #{binary() => _},
'prepare' := [fun((_) -> any())],
'repo' := atom(),
'repo_opts' := [{atom(), _}],
'required' := [atom()],
'types' :=
'nil' |
#{atom() =>
atom() |
{'array', _} |
{'in', _} |
{'map', _} |
{'maybe', _} |
{'param', 'any_datetime'} |
{'parameterized', atom(), _}},
'valid?' := boolean(),
'validations' := [{atom(), _}]}}
But now here’s the weird thing. If I add |> IO.inspect()
the error disappears!?:
projects
|> Projects.create_many_notify(socket.assigns.study.id)
|> IO.inspect()
|> case do
{:error, changeset} ->
changeset.errors
_ ->
nil
end
I can’t for the life of me figure out why…