phoenixframework / phoenix_html

Building blocks for working with HTML in Phoenix

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`mix dialyzer` error when upgrading `phoenix_html 3.3.1 -> 3.3.2`

chrishop opened this issue · comments

I upgraded my project from phoenix_html 3.3.1 -> 3.3.2 because of it mix dialyzer failed with the following error:

lib/my_project_web/live/organisations_live/vendors/form_component.ex:12:no_return
The created anonymous function has no local return.
________________________________________________________________________________
done (warnings were emitted)
Halting VM with exit status 2

form_component:12 just points to the top line of the render/1 function

If I roll back to version 3.3.1 the dialyzer passes.

relevant deps:

phoenix: 1.7.7,
phoenix_ecto: 4.4.2,
phoenix_html: 3.3.1,
phoenix_live_dashboard: 0.8.0,
phoenix_live_reload: 1.4.1,
phoenix_live_view: 0.19.5,
phoenix_pubsub: 2.1.3,
phoenix_template: 1.0.3,
phoenix_view: 2.0.2,

elixir/erlang versions:

elixir 1.14.3-otp-25
erlang 25.3.2

Looking into the diff between the 3.3.1 and 3.3.2 it seems like this could be due to:

+* Deprecations
+  * Deprecate `inputs_for/2` and `inputs_for/3` (without anonymous functions)

I can't really see anything else that would have caused it!

I have a minimal example here:

defmodule MyProjectWeb.Vendors.FormComponent do

  use MyProjectWeb, :live_component

  @doc false
  @impl true
  def render(assigns) do
    ~H"""
    <div>
      <.simple_form
        :let={f}
        for={@form}
      >
        <%= for access_info <- inputs_for(f, :access_info) do %>
        <% end %>
      </.simple_form>
    </div>
    """
  end
end

has exactly the same error:

lib/strong_compute_web/live/organisations_live/vendors/form_component.ex:12:no_return
The created anonymous function has no local return.
________________________________________________________________________________
done (warnings were emitted)
Halting VM with exit status 2

We no longer support that style of inputs_for. I believe that's the root cause. Use <.inputs_for ...> instead. You should also be getting a deprecation warning at runtime. :)

Ah we hadn't actually tried running the code in the Dependabot branch - I'd checked for compilation warnings but saw none.

warning: inputs_for/3 without an anonymous function is deprecated. If you are using 
Phoenix.LiveView, use the new Phoenix.Component.inputs_for/1 component
  (phoenix_html 3.3.2) lib/phoenix_html/form.ex:606: Phoenix.HTML.Form.inputs_for/3
  (my_app 0.73.1) lib/my_app_web/live/organisations_live/vendors/form_component.ex:32: 
anonymous fn/3 in MyAppWeb.Vendors.FormComponent.render/1

There we go, mystery solved :D

(I can't close the issue, but if anyone would like to, please do :) )