-
Notifications
You must be signed in to change notification settings - Fork 150
Open
Description
Describe the bug
The Surface formatter plugin (v0.12.1) is incompatible with Elixir 1.19.0-rc.0. When running mix format on .sface files, the formatter fails with a protocol error, incorrectly treating keyword list expressions in attributes as BitStrings.
Error message
mix format failed for file: lib/enaia_web/surface/forms/landlord_deal/steps/details_form.sface
** (Protocol.UndefinedError) protocol Enumerable not implemented for BitString.
Got value:
"[for: for_id]"
(elixir 1.19.0-rc.0) lib/enum.ex:5: Enumerable.impl_for!/1
(elixir 1.19.0-rc.0) lib/enum.ex:234: Enumerable.slice/1
(elixir 1.19.0-rc.0) lib/enum.ex:4713: Enum.slice_count_and_fun/2
(elixir 1.19.0-rc.0) lib/enum.ex:3031: Enum.slice_range/4
(surface 0.12.1) lib/surface/formatter/phases/render.ex:451: Surface.Formatter.Phases.Render.format_attribute_expression/2
(surface 0.12.1) lib/surface/formatter/phases/render.ex:374: Surface.Formatter.Phases.Render.render_attribute/2
(elixir 1.19.0-rc.0) lib/enum.ex:1688: Enum."-map/2-lists^map/1-1-"/2
How to reproduce
- Use Elixir 1.19.0-rc.0
- Have Surface 0.12.1 in your project
- Create a
.sfacefile with a slot that uses:letwith keyword list syntax:<:company_name_label :let={for: for_id}> - Run
mix format
Root cause
The Surface formatter at lib/surface/formatter/phases/render.ex:451 (in format_attribute_expression/2) appears to be receiving keyword list expressions as strings (BitStrings) instead of proper AST structures when running under Elixir 1.19.0-rc.0.
Fix
PR #767 fixes this by using IO.iodata_to_binary and String.slice instead of Enum.slice.
Workaround
Temporarily disable the Surface.Formatter.Plugin in .formatter.exs:
plugins: [
# Surface.Formatter.Plugin, # Temporarily disabled due to Elixir 1.19.0-rc.0 incompatibility
Phoenix.LiveView.HTMLFormatter,
# ... other plugins
]Environment
- Surface: v0.12.1
- Elixir: v1.19.0-rc.0
- Phoenix LiveView: v1.0.0
dougw-bc and goulvenclech
Metadata
Metadata
Assignees
Labels
No labels