Elixir 1.19: Fix typing violation on struct updates in Pleroma.Marker
warning: a struct for Pleroma.Marker is expected on struct update:
%Pleroma.Marker{marker | user: user}
but got type:
dynamic()
where "marker" was given the type:
# type: dynamic()
# from: lib/pleroma/marker.ex
{:ok, marker}
when defining the variable "marker", you must also pattern match on "%Pleroma.Marker{}".
hint: given pattern matching is enough to catch typing errors, you may optionally convert the struct update into a map update. For example, instead of:
user = some_function()
%User{user | name: "John Doe"}
it is enough to write:
%User{} = user = some_function()
%{user | name: "John Doe"}
typing violation found at:
│
81 │ {:ok, marker} -> %__MODULE__{marker | user: user}
│ ~
│
└─ lib/pleroma/marker.ex:81:24: Pleroma.Marker.get_marker/2
This commit is contained in:
parent
6bbfba7f6e
commit
dfaabb48ef
1 changed files with 1 additions and 1 deletions
|
|
@ -78,7 +78,7 @@ defmodule Pleroma.Marker do
|
||||||
|
|
||||||
defp get_marker(user, timeline) do
|
defp get_marker(user, timeline) do
|
||||||
case Repo.find_resource(get_query(user, timeline)) do
|
case Repo.find_resource(get_query(user, timeline)) do
|
||||||
{:ok, marker} -> %__MODULE__{marker | user: user}
|
{:ok, %__MODULE__{} = marker} -> %__MODULE__{marker | user: user}
|
||||||
_ -> %__MODULE__{timeline: timeline, user_id: user.id}
|
_ -> %__MODULE__{timeline: timeline, user_id: user.id}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue