don't enumerate a struct with Map.new in diff.ex#3970
don't enumerate a struct with Map.new in diff.ex#3970zachdaniel wants to merge 1 commit intophoenixframework:mainfrom
Map.new in diff.ex#3970Conversation
| resolve_templates(Map.put(rendered, @static, Map.fetch!(template, static)), template) | ||
| end | ||
|
|
||
| defp resolve_templates(%struct{} = rendered, template) do |
There was a problem hiding this comment.
I'm not sure how structs were really meant to be handled here, but this seemed reasonable with limited knowledge.
There was a problem hiding this comment.
Can you show the template where this happens?
There was a problem hiding this comment.
The stack trace didn't contain the line number or file so it took a while to track it down, sorry 😆.
It is in our app.html.heex, which looks roughly like this:
<div class="flex h-screen bg-white">
<%= if assigns[:current_user] do %>
<MyAppWeb.Components.Sidebar.component
id="sidebar"
current_user={@current_user}
/>
<div class="flex-1 ml-64 max-w-[calc(100%-16rem)]">
<header class="bg-white shadow-xs">
<div class="px-4 sm:px-6 lg:px-8 py-4">
<div class="flex items-center justify-between">
<h1 class="text-xl font-semibold text-gray-900">
{assigns[:page_title] || "Page title"}
</h1>
<div class="flex items-center">
<%= if assigns[:current_user] do %>
<span class="text-sm text-gray-700 mr-4">{@current_user.email}</span>
<.link href={~p"/sign-out"} class="text-sm text-gray-700 hover:text-gray-900">
Sign out
</.link>
<% else %>
<.link href={~p"/sign-in"} class="text-sm text-gray-700 hover:text-gray-900">
Sign in
</.link>
<% end %>
</div>
</div>
</div>
</header>
<main class="px-4 py-8 sm:px-6 lg:px-8">
<.flash_group flash={@flash} />
{@inner_content}
</main>
</div>
<% else %>
<div class="flex-1">
<main class="px-4 py-8 sm:px-6 lg:px-8">
<.flash_group flash={@flash} />
{@inner_content}
</main>
</div>
<% end %>
</div>The problematic area is here:
<span class="text-sm text-gray-700 mr-4">{@current_user.email}</span>in Ash case insensitive strings have their type retained with a struct, i.e %Ash.CiString{value: "email"}, and that is the struct that gets matched in my example.
There was a problem hiding this comment.
that struct implements to String.Chars protocol which is what I believe is being used to display the value
This resolves an issue encountered while upgrading to 1.1
The stack traces shows
1.2.0-devbecause I cloned it locally while testing, but the error is present in prior versions.