Fl4m3Ph03n1x

Fl4m3Ph03n1x

Elixir Desktop has dialyzer issues in MenuBar

Background

I have a small app using Elixir Desktop. This app works relatively well and launches without issues:

However, I have dialyzer complaining about types. I am not sure if this is a false positive, or if I am doing something wrong.

Problem

I have a MenuBar in my application with some basic functionality. This MenuBar is as far as I understand, a Phoenix LiveView component (because it has a mount and a render functions). So this code should look familiar for most users of Phoenix and LiveView:

defmodule WebInterface.Live.MenuBar do
  @moduledoc """
  Menubar that is shown as part of the main Window on Windows/Linux. In
  MacOS this Menubar appears at the very top of the screen.
  """

  use Desktop.Menu

  alias Desktop.{Menu, Window}

  @impl Menu
  def render(assigns) do
    ~H"""
    <menubar>
      <menu label="File">
          <hr/>
          <item onclick="quit">Quit</item>
      </menu>
    </menubar>
    """
  end

  @impl Menu
  def handle_event("quit", menu) do
    Window.quit()
    {:noreply, menu}
  end

  @impl Menu
  def mount(menu), do: {:ok, menu}

  @impl Menu
  def handle_info(:changed, menu), do: {:noreply, menu}

end

The issue here is that Dialyzer is complaining about my render function:

Type mismatch for @callback render/1 in Desktop.Menu behaviour.

Expected type:
binary()

Actual type:
%Phoenix.LiveView.Rendered{
  :dynamic => (_ -> []),
  :fingerprint => 15_721_876_439_225_774_806_119_511_245_371_375_581,
  :root => true,
  :static => [<<_::1480>>, ...]
}

It says it expects a String instead of an H sigil. Which is confusing to me, because the latest version does support this sigil.

Question

So the question arises. What am I doing wrong and how can I fix this?

Marked As Solved

Also Liked

Fl4m3Ph03n1x

Fl4m3Ph03n1x

So this is something a PR with the correct type could fix right ?
Thank you for confirming my suspicion @al2o3cr !

dominicletz

dominicletz

Creator of Elixir Desktop

Thanks guys, sometimes I just can’t figure out what dialyzer is trying to tell me, will look into this and fix!

Where Next?

Popular in Questions Top

albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call t...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" =&gt; #BSON.ObjectId&lt;58eb1a7a9ad169198c3dXXXX&gt;, "email" =&gt; ...
New

Other popular topics Top

senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 53690 245
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 39297 209
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 47930 226
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New

We're in Beta

About us Mission Statement