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:

The created anonymous function has no local return.

Here is the content of the file:

  <.input field={{f, :title}} label={gettext("Title")} />
    field={{f, :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><%= gettext("Save") %></.button>
    <.button phx-click="cancel"><%= gettext("Cancel") %></.button>
<%= if @live_action == :edit do %>
<% 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).

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.

According to the changelog for Phoenix.HTML, both inputs_for/2 and inputs_for/3 were recently deprecated though inputs_for/4 remains. inputs_for/4 also happens to expect an anonymous function which probably explains the dialyzer error you’re seeing.

v3.3.2 (2023-08-10)

  • Enhancements
    • Address deprecations in Elixir v1.16+
  • Deprecations
    • Deprecate inputs_for/2 and inputs_for/3 (without anonymous functions)

While you could try getting Phoenix.HTML.Form.inputs_for/4 to work, it seems like a good opportunity to swap it out for the newer Phoenix.Component.inputs_for/1 instead.

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.