Function template_not_found/2 has no local return

For the past few days, I am getting a Dialyzer warning Function template_not_found/2 has no local return with all the view definitions.

defmodule MyAppWeb.LayoutView
   use MyAppWeb, :view

is generating a warning that template_not_found/2 has no local return

Any idea what the change is?

A template_not_found/2 function is generated by Phoenix in error_view.ex:

Is that function still the same in your application?

1 Like

Thanks. The issue is resolved now.

I recently upgraded a project from phx from 1.4 to 1.6 and am seeing the same dialyzer warnings for each of my _view.exs files.

Function template_not_found/2 has no local return.
Function template_not_found/2 has no local return.
Function template_not_found/2 has no local return.
done (warnings were emitted)

I decompiled my page_view module and I saw it had the following, which makes the dialyzer warnings 100% on point:

template_not_found(_@1, _@2) ->

This in turn suggests a default implementation is inserted which throws doesn’t seem to care about ErrorView unless something catches the error raised before delegating back to error view…

I understand <WebApp>.ErrorView.template_not_found/2 is the fallback action for all views(?).

defmodule BondWeb.ErrorView do
  use BondWeb, :view

  def template_not_found(template, _assigns) do

Either way, is this warning from dialyzer going to need to be appeased by adding the default implementation in which mimics or delegates to the ErrorView generated function?

1 Like

Had the same problem, all my view modules generated a warning.
Did a mix deps.update --all which updated phoenix_view from 1.1.1 to 1.1.2 and the warnings disappeared.

Not sure that phoenix_view version is the problem, but updating did fix it for me.


1.1.2 does appear to be specifically focused on addressing this problem:

1 Like

I had updated all my explicit deps to latest, but I had missed this possibility.

$ mix deps.update --all

  gettext 0.19.0 => 0.19.1
  phoenix_view 1.1.1 => 1.1.2
  plug 1.12.1 => 1.13.2
$ mix dialyzer


Total errors: 0, Skipped: 0, Unnecessary Skips: 0



This should be marked as a solution.