Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
MrAustin2u opened this issue Aug 6, 2024 · 3 comments · Fixed by #541

Comments

@MrAustin2u
Copy link

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() | #{'location_id':=<<:288>>, =>},#{'context':=atom() | #{'current_business_id':=<<: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
Copy link

nietaki commented Sep 2, 2024

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
Copy link

slondr commented Sep 10, 2024

I can reproduce this with a very simple example:

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

@crertel-getthru
Copy link

+1 we hit this too today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants