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?
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #performance










First 4 of 4 Posts
al2o3cr
The typespec of
Desktop.Menu.renderis incorrect:https://github.com/elixir-desktop/desktop/blob/cf8322cc8d8e4a2148e528bf0f0b2ee9edb6a10b/lib/desktop/menu.ex#L128
Fl4m3Ph03n1x
So this is something a PR with the correct type could fix right ?
Thank you for confirming my suspicion @al2o3cr !
dominicletz
Thanks guys, sometimes I just can’t figure out what dialyzer is trying to tell me, will look into this and fix!
Fl4m3Ph03n1x
Fixed with PR:
https://github.com/elixir-desktop/desktop/issues/17