Description
Elixir and Erlang/OTP versions
Erlang/OTP 27 [erts-15.2] [source] [64-bit] [smp:10:10] [ds:10:10:10] [async-threads:1] [jit] [dtrace]
Elixir 1.19.0-dev (compiled with Erlang/OTP 27)
(running off main — be17d71)
Operating system
MacOS 14.5
Current behavior
I was testing the new parallel deps compilation in Elixir 1.19-dev main and looking at the deprecation warnings when I got this one:
warning: this clause of defp maybe_mark_for_deletion/2 is never used
│
646 │ defp maybe_mark_for_deletion(%Ecto.Changeset{changes: %{marked_as_deleted: true}} = changeset, module) do
│ ~
│
└─ lib/my_app/blueprint.ex:646:8: MyApp.Blueprint.maybe_mark_for_deletion/2
This is the code:
defp maybe_mark_for_deletion(%Ecto.Changeset{changes: %{marked_as_deleted: true}} = changeset, module) do
if module.__allow_mark_as_deleted__ do
%{changeset | action: :delete}
else
changeset
end
end
defp maybe_mark_for_deletion(changeset, _) do
changeset
end
It gets called from a run_changeset
pipeline → maybe_mark_for_deletion(changeset, module)
My code is in a library and run_changeset
gets called with user code, so how would the compiler know that the clause never gets used?
I noticed that module.__allow_mark_as_deleted__
should have parens, since it's a function. When I added them (module.__allow_mark_as_deleted__()
), the warning disappeared.
Expected behavior
The function clause is in fact in use, so wouldn't expect that warning.