Skip to content

Disconnected module uses an invalid render function with OTP 24 #8

@sevenseacat

Description

@sevenseacat

This is a bit of an odd one. I'm testing my app to verify my specification of minimum version requirements, and have come across a bug in Flashy I think.

My Disconnected module is defined like the following:

defmodule MyAppWeb.Components.Flash.Disconnected do
  @moduledoc false
  use MyAppWeb, :component
  use Flashy.Disconnected

  attr :key, :string, required: true

  def render(assigns) do
    options = Flashy.Normal.Options.new(dismissible?: false, closable?: false)
    assigns = assign(assigns, :options, options)

    ~H"""
    <Flashy.Disconnected.render key={@key}>
      (rendering stuff in here)
    </Flashy.Disconnected.render>
    """
  end
end

This works great with Elixir 1.15 and Erlang 26.

However, if I downgrade to Erlang 24, I get the following error:

[error] ** (UndefinedFunctionError) function MyAppWeb.Components.Flash.Disconnected."-fun.render/1-"/1 is undefined or private
    (myapp 0.1.0) MyAppWeb.Components.Flash.Disconnected."-fun.render/1-"(%{__changed__: nil, __given__: %{__changed__: nil, key: "disconnected", notification: %Flashy.Disconnected{component: %Flashy.Component{function_name: :"-fun.render/1-", module: MyAppWeb.Components.Flash.Disconnected}}}, key: "disconnected", notification: %Flashy.Disconnected{component: %Flashy.Component{function_name: :"-fun.render/1-", module: MyAppWeb.Components.Flash.Disconnected}}, rest: %{}})
    (flashy 0.2.7) lib/flashy/container.ex:47: anonymous fn/2 in Flashy.Container."render_notification (overridable 1)"/1
    (flashy 0.2.7) /Users/rebecca/Projects/book/testing/myapp/deps/flashy/lib/flashy/container.ex:29: Flashy.Container.render/1
    (elixir 1.15.0) lib/enum.ex:2510: Enum."-reduce/3-lists^foldl/2-0-"/3
    ...

It seems to be something in this line https://github.com/sezaru/flashy/blob/master/lib/flashy/disconnected.ex#L7 - printing out debug things shows this:

[lib/flashy/container.ex:17: Flashy.Container.render/1]
Application.fetch_env!(:flashy, :disconnected_module).new() #=> %Flashy.Disconnected{
  component: %Flashy.Component{
    function_name: :"-fun.render/1-",
    module: MyAppWeb.Components.Flash.Disconnected
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions