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

Fl4m3Ph03n1x

Fl4m3Ph03n1x

Fixed with PR:

Also Liked

al2o3cr

al2o3cr

The typespec of Desktop.Menu.render is incorrect:

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

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
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 record...
New
New
Werner
Hi, I’m using Ubuntu 18.04 and after updating to OTP-24.0 yesterday i have this warning when I run “mix local.hex”: 14:57:30.512 [warn] ...
New
Kagamiiiii
Student &amp; New to elixir. Nice language. I want to convert a english character, e.g. “a”, which is stored in a variable, to it’s asci...
New
dokuzbir
Hello, I am trying to convert my lists to string without losing brackets.For start i have 3 map. They look like these buyer = %{ id: ...
New
sacepums
Hey guys. I'm new to elixir and im really stocked about it. But I ran into a bit of problem - I need to convert a date sting, for examp...
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
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
LegitStack
I’m trying to make a websocket server in Phoenix or raw Elixir. I heard about gun, I think I could use cowboy, but since I’m not that sma...
New

Other popular topics Top

sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
977 41022 311
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
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
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
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
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New

We're in Beta

About us Mission Statement