surface-ui / surface

A server-side rendering component library for Phoenix
https://surface-ui.org
MIT License
2.04k stars 152 forks source link

Erlang Error in Elixir Language Server with Surface #701

Open lucas-stellet opened 1 year ago

lucas-stellet commented 1 year ago

Describe the bug

I started a new project from zero using the mix phx.new, and then I ran the mix surface.init --demo --catalogue --layouts to set up Surface.

After I started to follow the Getting Started guide, I realized there is no Surface intellisense when I started to write the slot macro.

I use Visual Studio Code with ElixirLS extension.

Checking the elixir-ls logs I could see the log below:

[Warn  - 16:16:39] ** (ErlangError) Erlang error: "ArgumentError during metadata build pre:\ncould not call Module.register_attribute/3 because the module NoahWeb.Components.ExampleComponent is already compiled\nast node: {:use, [end_of_expression: [newlines: 0, line: 2, column: 24], line: 2, column: 3], [{:__aliases__, [last: [line: 2, column: 15], line: 2, column: 7], [:Surface, :Component]}]}"
    (elixir 1.15.4) lib/module.ex:2310: Module.assert_not_readonly!/2
    (elixir 1.15.4) lib/module.ex:1660: Module.register_attribute/3
    (surface 0.11.0) expanding macro: Surface.BaseComponent.__using__/1
    nofile: NoahWeb.Components.ExampleComponent (module)

How to reproduce it

Create a new project with the last version of Phoenix. Add the last version of surface. Use Visual Studio Code with ElixirLS extension. Both in the last version released.

The behavior you expected

Your Environment

Surface: v0.11.0 LiveView: v0.19.5 Elixir: v1.15.4 Erlang: v26.0.2

dougw-bc commented 1 year ago

I have noticed the same, and think it's related to elixir 1.15.x and maybe erlang 26.