surface-ui / surface

A server-side rendering component library for Phoenix

Home Page:https://surface-ui.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dialyzer issues in v0.9.0

elliotb opened this issue · comments

Describe the bug

Since upgrading to Surface v0.9 (and LiveView 0.18.0), we're getting dialyzer issues across our project for all LiveViews and (live and non-live) components, of the form:

[filename].ex:1:pattern_match
The pattern can never match the type.

Pattern:
false

Type:
true

These seem similar to the issues reported in #654, which looked to be resolved by v0.9.0.

How to reproduce it

This is occurring in a private repo with hundreds of LiveViews and components, but I can share some of the code relevant to e.g. use MyAppWeb, :surface_live_view:

def surface_live_view do
    quote do
      use Surface.LiveView, layout: {MyAppWeb.LayoutView, "live.html"}

      import MyAppWeb.MountHelpers

      unquote(view_helpers())
    end
end

defp view_helpers do
    quote do
      # Use all HTML functionality (forms, tags, etc)
      use Phoenix.HTML

      # Import LiveView helpers (live_render, live_component, live_patch, etc)
      import Phoenix.LiveView.Helpers

      # Import basic rendering functionality (render, render_layout, etc)
      import Phoenix.View

      import MyAppWeb.{
        BooleanHelpers,
        DateTimeHelpers,
        ErrorHelpers,
        Gettext,
        JSHelpers,
        LiveViewHelpers,
        NameHelpers,
        NumberHelpers,
        PupilPhotoHelpers
      }

      alias MyAppWeb.LegacyRoutes
      alias MyAppWeb.Router.Helpers, as: Routes
    end
  end

The behavior you expected

No dialyzer issues to occur.

Your Environment

Surface: v0.9.0
LiveView: v0.18.0
Elixir: v1.13.4

Brilliant, thanks @msaraiva. I can confirm that this resolves the issues for our app.