From 8e5e7fe59de9502c68337e03dc7a0b58df89af31 Mon Sep 17 00:00:00 2001 From: Neil Berkman Date: Sat, 6 Sep 2025 14:10:52 -0700 Subject: [PATCH] Fix Elixir 1.19.0-rc.0 formatter compatibility Code.format_string! returns iodata, not a list, so Enum.slice fails. Changed to use IO.iodata_to_binary and String.slice instead. This fixes the Enumerable protocol error when formatting Surface templates with keyword list attributes in Elixir 1.19.0-rc.0. --- lib/surface/formatter/phases/render.ex | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/surface/formatter/phases/render.ex b/lib/surface/formatter/phases/render.ex index 603aa074..caf49fdf 100644 --- a/lib/surface/formatter/phases/render.ex +++ b/lib/surface/formatter/phases/render.ex @@ -448,12 +448,12 @@ defmodule Surface.Formatter.Phases.Render do # handle keyword lists, which will be stripped of the outer brackets per surface syntax sugar "[#{expression}]" |> Code.format_string!(locals_without_parens: [...: 1]) - |> Enum.slice(1..-2//1) - |> to_string() + |> IO.iodata_to_binary() + |> String.slice(1..-2//1) else expression |> Code.format_string!(locals_without_parens: [...: 1]) - |> to_string() + |> IO.iodata_to_binary() end if length(Keyword.get(opts, :attributes, [])) > 1 do