None of these warnings were output by Dialyzer before the upgrade and none of the relevant code for the warnings has changed.
One set of warnings is covered by this GitHub issue:
The Dialyzer warning:
The function call will not succeed.
:pot.valid_totp(_token :: binary(), binary(), [{:window, 1}])
will never return since it differs in arguments with
positions 3rd from the success typing arguments:
(binary(), any(), [{:token_length, pos_integer()}])
Basically, this function throws the warning:
defmodule PotDialyzerWarningRepro do
def totp_valid?(token, secret) do
:pot.valid_totp(token, secret, [{:window, 1}])
end
end
But this Erlang code – which seems functionally equivalent, doesn’t:
-module(pot_dialyzer_warning_repro_erl).
-export([is_totp_valid/2]).
is_totp_valid(Token, Secret) ->
pot:valid_totp(Token, Secret, [{window, 1}]).
Changing the 3rd argument in the Elixir code to include the :token_length
option does resolve the warning.
Here’s an example of another set of (pairs of) interesting warnings:
web/templates/merchant/freshbooks/_scripts.invoices.html.eex:1:no_return
Function _scripts.invoices.html/1 has no local return.
________________________________________________________________________________
web/templates/merchant/freshbooks/_scripts.invoices.html.eex:1:call
The function call will not succeed.
Partially.Merchant.FreshbooksView.render(
Partially.Merchant.QuickbooksView,
<<95, 115, 99, 114, 105, 112, 116, 115, 46, 105, 110, 118, 111, 105, 99, 101, 115, 46,
104, 116, 109, 108>>
)
will never return since it differs in arguments with
positions 1st from the success typing arguments:
(
binary()
| maybe_improper_list(
binary() | maybe_improper_list(any(), binary() | []) | char(),
binary() | []
),
any()
)
________________________________________________________________________________
Here’s the contents of web/templates/merchant/freshbooks/_scripts.invoices.html.eex
:
<%= render Partially.Merchant.QuickbooksView, "_scripts.invoices.html" %>
and here’s the corresponding view (web/views/merchant/freshbooks_view.ex
):
defmodule Partially.Merchant.FreshbooksView do
use Partially.Web, :view
end
The use Partially.Web, :view
itself (generates code that) calls use Phoenix.View
.
Based on the Phoenix.View
source the generated render/2
function, the template code should be handled by this clause:
def render(module, template) when is_atom(module) do
Phoenix.View.render(module, template, %{})
end
I’m note sure where Dialyzer is getting the “success typing arguments”. It looks like maybe from the render_template/2
function(s) generated by Phoenix.Template
perhaps.
Both warnings can be resolved by changing the template code to this:
<%= render Partially.Merchant.QuickbooksView, "_scripts.invoices.html", [] %>
But beyond resolving the warnings, I’m curious to know what they mean and why they seem to only have suddenly appeared after our recent Elixir upgrade.