Problem with dialyzer and Phoenix LiveView (app_call requires that _@)

Hello, when I run mix dialyzer I have some errors like this:

lib/mishka_html_web/live/blog_post_live.ex:46:app_call
The call _.'id'/() requires that _@3 is of type atom(), not [any()].
________________________________________________________________________________
lib/mishka_html_web/live/blog_post_live.ex:143:app_call
The call _.'user_full_name'/() requires that _@4 is of type atom(), not tuple().
________________________________________________________________________________
lib/mishka_html_web/live/blog_post_live.ex:378:app_call
The call _.'id'/() requires that _@4 is of type atom(), not [any()].

when I check the lines of them I cant find anything which is problem just a simple code of liveview

line46:

Process.send_after(self(), {:load_links, post.id}, 4000)

line143:

socket
|> assign(component: MishkaHtmlWeb.Client.BlogPost.SubComment, open_modal: true, sub_comment: %{
 full_name: record.user_full_name,
 description: record.description
})

line378:

socket
|> assign(like: Like.count_post_likes(post.id, socket.assigns.user_id))

how can I fix this?

project:

It seems you added a wrong typespec on the Post.post (apps/mishka_content/lib/blog/post.ex)

@spec post(String.t(), String.t() | atom()) :: map() | list() | nil
  def post(alias_link, status) do

It should probably be more like

@spec post(String.t(), String.t() | atom()) :: map() | nil
  def post(alias_link, status) do

I would try to first remove this spec and check if dialyzer is happier without it.

1 Like

Thanks it helped me to solve 2 of them

and the other was fixed by replacing

@spec comment([{:filters, map()} | {:user_id, data_uuid()}, ...]) :: map() | nil
  def comment(filters: filters, user_id: user_id) do

instead of this:

@spec comment([{:filters, map()} | {:user_id, data_uuid()}, ...]) :: map() | nil | tuple()
1 Like