jeremyjh / dialyxir

Mix tasks to simplify use of Dialyzer in Elixir projects.
Apache License 2.0
1.69k stars 141 forks source link

Unknown error occurred: %FunctionClauseError{module: Dialyxir.Warnings.InvalidContract, function: :format_long, arity: 1, kind: nil, args: nil, clauses: nil} #539

Open MrAustin2u opened 1 month ago

MrAustin2u commented 1 month ago

Unknown error occurred: %FunctionClauseError{module: Dialyxir.Warnings.InvalidContract, function: :format_long, arity: 1, kind: nil, args: nil, clauses: nil}

Legacy warning: lib/blvd_graph/business/resolvers/booking_line.ex:11: Invalid type specification for function 'Elixir.BlvdGraph.Business.Resolvers.BookingLine':resolve_is_incoming_number_registered/2. The success typing is 'Elixir.BlvdGraph.Business.Resolvers.BookingLine':resolve_is_incoming_number_registered(atom() | #{'locationid':=<<:288>>, =>},#{'context':=atom() | #{'current_businessid':=<<:288>>, 'loader':=map(), =>}, =>}) -> {'middleware','Elixir.Absinthe.Middleware.Dataloader',{,}} But the spec is 'Elixir.BlvdGraph.Business.Resolvers.BookingLine':resolve_is_incoming_number_registered('Elixir.Absinthe.Resolution':arguments(),'Elixir.Absinthe.Resolution':t()) -> {'ok',#{'is_registered':=boolean()}} The return types do not overlap

nietaki commented 1 week ago

Similar thing in my case, so I'll just add more examples.

In my case:

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/grain/knowledge_graph/ask.ex:334: Invalid type specification for function 'Elixir.Grain.KnowledgeGraph.Ask':insert_evaluation/3.
 The success typing is 'Elixir.Grain.KnowledgeGraph.Ask':insert_evaluation(_,_,_) -> {'error',_} | {'ok',#{'__struct__':='Elixir.Grain.VectorModels.AskEvaluation', 'nodes':=maybe_improper_list(), _=>_}}
 But the spec is 'Elixir.Grain.KnowledgeGraph.Ask':insert_evaluation('Elixir.Ecto.UUID':t(),'Elixir.Ecto.UUID':t(),['Elixir.Grain.VectorModels.KeyElement':t()]) -> 'Elixir.Grain.VectorModels.AskEvaluation':t()
 The return types do not overlap

The warning is correct of course:

# typespec:
  @spec insert_evaluation(Ecto.UUID.t(), Ecto.UUID.t(), [KeyElement.t()]) :: AskEvaluation.t()
# actual return
        {:ok, %AskEvaluation{evaluation | nodes: nodes}}

versions:

$ iex --version                                                                                                                                                                                                                                                                      1 ↵
Erlang/OTP 27 [erts-15.0.1] [source] [64-bit] [smp:10:10] [ds:10:10:10] [async-threads:1] [jit]

IEx 1.17.2 (compiled with Erlang/OTP 27)

$ mix hex.outdated | grep dial
dialyxir                      1.4.3      1.4.3      Up-to-date
slondr commented 5 days ago

I can reproduce this with a very simple example:

@spec foobar(string()) :: integer()
def foobar(r) do
    false
end