You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@spec abc(Q.t(), R.t()) :: {:ok, X.Adapter.result()} | {:error, String.t()}
def abc(terminal, tx) do
{:error, {:a, :b}}
end
Unknown error occurred: %FunctionClauseError{module: Dialyxir.Warnings.InvalidContract, function: :format_long, arity: 1, kind: nil, args: nil, clauses: nil}
Legacy warning:
lib/x/adapters/y/payments.ex:52: Invalid type specification for function 'Elixir.X.Adapters.Y.Payments':abc/2.
The success typing is 'Elixir.X.Adapters.Y.Payments':abc(_,_) -> {'error',{'a','b'}}
But the spec is 'Elixir.X.Adapters.Y.Payments':abc('Elixir.X.Z.Q':t(),'Elixir.X.Z.R':t()) -> {'ok','Elixir.X.Adapter':result()} | {'error','Elixir.String':t()}
The return types do not overlap
This function was intentionally implemented as-is, to test/verify dialyzer/dialyxir works, because there is another function that violates the spec, but dialyzer/dialyxir doesn't catch it at all for some reason.
Expected behavior
The text was updated successfully, but these errors were encountered:
This function was intentionally implemented as-is, to test/verify dialyzer/dialyxir works, because there is another function that violates the spec, but dialyzer/dialyxir doesn't catch it at all for some reason.
PROBLEM:
I noticed, that dialyzer/dyalixir doesn't do type-check or type inference for the function with hard mistakes, by example, the spec says - :: {:ok, map()} | {:error, String.t()} but the function return {:ok, map()} or {:error, String.t()} or {:error, nil} or even in my tests {:e1rror, 123}.
For example, NO ERROR:
def xr(x, y) do
case :rand.uniform(100) do
x when x > 50 ->
{:ok, %{body: "asdasdasasd"}}
_ ->
{:error, :woop}
end
end
@spec start_tx(Q.t(), R.t()) :: {:ok, %{}} | {:error, String.t()}
def start_tx(terminal, tx) do
case xr(terminal, tx) do
{:ok, %{body: body}} ->
json = string_to_map(body)
case Map.get(json, "TRANSACTION_ID") do
nil ->
{:e1rror, 123}
outertxid ->
{:ok, %{}}
end
{:error, any} ->
{:error, "bank unavailable"}
end
end
BUT when I removed the
outertxid ->
{:ok, %{}}
finally, I got an error:
The type specification has too many types for the function.
Function:
Elixir.X.Adapters.Y.Payments.start_tx/2
Extra type:
{:ok, %{}}
Success typing:
{:e1rror, 123} | {:error, <<_::128>>}
Please file a bug in https://github.com/jeremyjh/dialyxir/issues with this message.
Unknown error occurred: %FunctionClauseError{module: Dialyxir.Warnings.InvalidContract, function: :format_long, arity: 1, kind: nil, args: nil, clauses: nil}
Legacy warning:
lib/benchee/formatters/html.ex:43: Invalid type specification for function 'Elixir.Benchee.Formatters.HTML':format/2.
The success typing is 'Elixir.Benchee.Formatters.HTML':format(#{'__struct__':='Elixir.Benchee.Suite', 'configuration':=#{'__struct__':='Elixir.Benchee.Configuration', 'unit_scaling':=_, _=>_}, 'scenarios':=_, 'system':=atom() | #{'available_memory':=_, 'cpu_speed':=_, 'elixir':=_, 'erlang':=_, 'num_cores':=_, 'os':=_, _=>_}, _=>_},map()) -> [any(),...]
But the spec is 'Elixir.Benchee.Formatters.HTML':format('Elixir.Benchee.Suite':t(),map()) -> #{['Elixir.String':t()]:='Elixir.String':t()}
The return types do not overlap
The fix was simple, I had forgotten to adapt a spec where I switched from map to list of tuples:
Environment
Current behavior
This function was intentionally implemented as-is, to test/verify dialyzer/dialyxir works, because there is another function that violates the spec, but dialyzer/dialyxir doesn't catch it at all for some reason.
Expected behavior
The text was updated successfully, but these errors were encountered: