Bypass provides a quick way to create a custom plug that can be put in place instead of an actual HTTP server to return prebaked responses to client requests.
In a codebase where I use bypass and dialyzer I have been getting "Function [...] has no local return" errors whenever I call Bypass.open.
I think that the issue is coming from inside Bypass. Running dialyzer on Bypass gives me the following errors:
lib/bypass/instance.ex:320:no_return
Function do_up/2 has no local return.
________________________________________________________________________________
lib/bypass/instance.ex:324:call
The function call will not succeed.
Plug.Cowboy.http(
Bypass.Plug,
_plug_opts :: [pid(), ...],
_cowboy_opts :: [{:port, _} | {:ref, _} | {:transport_options, [{_, _}, ...]}, ...]
)
breaks the contract
(module(), Keyword.t(), Keyword.t()) ::
{:ok, pid()} | {:error, :eaddrinuse} | {:error, term()}
________________________________________________________________________________
done (warnings were emitted)
Halting VM with exit status 2
The function that it's failing on looks like this:
I think that the issue is plug_opts. The spec for Plug.Cowboy.http says that the second arg should be a Keyword.t(), but we're passing a list containing one element - the pid returned by self(). So, dialyzer thinks that the contract is being violated and the function call won't work.
In a codebase where I use bypass and dialyzer I have been getting "Function [...] has no local return" errors whenever I call
Bypass.open
.I think that the issue is coming from inside Bypass. Running dialyzer on Bypass gives me the following errors:
The function that it's failing on looks like this:
I think that the issue is
plug_opts
. The spec forPlug.Cowboy.http
says that the second arg should be aKeyword.t()
, but we're passing a list containing one element - the pid returned byself()
. So, dialyzer thinks that the contract is being violated and the function call won't work.