dlebrun

dlebrun

Dialyzer error in Heex file after updating LiveView

After updating phoenix_live_view from version 0.19.3 to version 0.19.5, I get the following error when I run Dialyzer:

lib/my_app_web/live/books/create_or_edit.html.heex:1:no_return
The created anonymous function has no local return.

Here is the content of the file:

<.simple_form
  :let={f}
  id={"edit-book-#{@book.id}"}
  for={@changeset}
  phx-change="validate"
  phx-submit="submit"
  as="form"
>
  <.input field={{f, :title}} label={gettext("Title")} />
  <.input
    field={{f, :language}}
    type="select"
    options={language_options()}
    label={gettext("Language")}
  />

  <fieldset class="flex flex-col gap-2">
    <legend><%= gettext("EBook formats") %></legend>
    <%= for ebook_form <- Phoenix.HTML.Form.inputs_for(f, :ebook_formats) do %>
      <.ebook_line form={ebook_form} />
    <% end %>
    <.button class="mt-2" type="button" phx-click="add-ebook">
      <Heroicons.document_plus class="w-6 h-6" />
    </.button>
  </fieldset>

  <:actions>
    <.button><%= gettext("Save") %></.button>
    <.button phx-click="cancel"><%= gettext("Cancel") %></.button>
  </:actions>
</.simple_form>
<%= if @live_action == :edit do %>
  <div>
    <.live_component
      module={MyAppWeb.SearchTagComponent}
      id="search_tag"
      selected_tags={@selected_tags}
    />
  </div>
<% end %>

I tried to remove the if section at the bottom, but the error still occurs.
Any idea what might be the problem?

Other information that might be relevant:

  • Elixir 1.15.4 / Erlang 26.0.2
  • dialyxir 1.3.0
  • Updating phoenix_live_view also updated the following packages: json, phoenix, phoenix_html, and phoenix_template (all patch-level updates).

First Post!

sodapopcan

sodapopcan

Hello and welcome to the forums :slight_smile:

I’m far from a dialyzer but expert but since you’re getting no bites I thought I’d respond and can hopefully help you diagnose.

Errors in anonymous functions can be a bit of pain sometimes since the reported failing line number is that of the callsite of the function that calls the anonymous function. In this case, that function is simple_form/1 which happens to be on line 1. That’s why removing the if did nothing since it’s not called within simple_form/1.

I guess that’s probably not much more information than you’ve probably already tried now but hopefully somewhat helpful. I’m assuming the error is in the list comprehension (for) since that is the only place I can that there is for sure an anonymous function call.

Last Post!

dbaer

dbaer

I ran into this too. After fiddling with clearing _build and various recompilations I managed to get Elixir to eek out the deprecation notice for inputs_for exactly once, and that pointed me in the right direction.

As an aside, It would be nice if compiler warnings were more consistent. Sometimes they show after an _build delete and recompile, sometimes they show up in production compile, sometimes in CI.

Where Next?

Popular in Questions Top

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
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
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs &amp; Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 130286 1222
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
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
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

We're in Beta

About us Mission Statement