Dialyzer error when using Phoenix.Router.match/5

Hey all!

Whenever I try to use Phoenix.Router.match/5 it trips dialyzer. I’m not sure if it’s me or Phoenix that has the problem. I’m also unable to figure out how to suppress the error using @dialyzer.


defmodule MyProject.Router do
  use Phoenix.Router

  match :*, "/*path", MyProject.Controllers.CatchAll, :not_found

Dialyzer Error

The pattern can never match the type.



     :conn => nil,
     :log => :debug,
     :path_params => map(),
     :pipe_through => [],
     :plug => MyProject.Controllers.CatchAll,
     :plug_opts => :not_found,
     :route => <<_::48>>
   }, (map(), map() -> map()), (_ -> any()),
   {MyProject.Controllers.CatchAll, :not_found}}

Thanks in advance!

The error indicates that Dialyzer found that this clause:

can never match because the router you’ve defined will always match.

This sounds similar-but-different to https://github.com/phoenixframework/phoenix/issues/2750, which involves a Dialyzer failure that causes the other clause in that case __match_route__ to never match.

Yes, I dove into the Phoenix.Router source and found that as well. I’m assuming this is an issue with Phoenix. It probably makes sense for me to open an issue.

I was able to suppress the error by adding this to .dialyzer_ignore.exs.

  { "lib/phoenix/router.ex", :pattern_match, 402 }

I hate doing this but I’m not sure what the alternative is right now.