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

typespec allows for async response from request functions #289

Merged
merged 1 commit into from
Sep 13, 2017

Conversation

jeffrom
Copy link

@jeffrom jeffrom commented Sep 12, 2017

currently this fails dialyzer checks:

def get do
  HTTPoison.get!(url, [], stream_to: self())
  |> read_response()
end

def read_response(%HTTPoison.AsyncResponse{}) do
end

dialyzer output:

The call 'Elixir.CoolModule':do_response(#{'__struct__':='Elixir.HTTPoison.Response', 'body':=_, 'headers':=[any()], 'request_url':=binary() |
 [binary() | maybe_improper_list(any(),binary() | []) | char()] | {'hackney_url',atom(),atom(),binary(),'undefined' | binary(),'nil' | 'undefined' | binary(),binary(),binary(),[any(
)],'undefined' | integer(),binary(),binary()}, 'status_code':=integer()}) will never return since it differs in the 1st argument from the success typing arguments: (#{'__struct__':=
'Elixir.HTTPoison.AsyncResponse', 'id':=_, _=>_})

and

The pattern #{'id':=_id@1, '__struct__':='Elixir.HTTPoison.AsyncResponse'} can never match the type #{'__struct__':='Elixir.HTTPoison.Response', 'body':
=_, 'headers':=[any()], 'request_url':=binary() | [binary() | maybe_improper_list(any(),binary() | []) | char()] | {'hackney_url',atom(),atom(),binary(),'undefined' | binary(),'nil'
 | 'undefined' | binary(),binary(),binary(),[any()],'undefined' | integer(),binary(),binary()}, 'status_code':=integer()}

Thanks for the great work!

@edgurgel edgurgel merged commit 8bb7341 into edgurgel:master Sep 13, 2017
@edgurgel
Copy link
Owner

Thanks!

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 this pull request may close these issues.

2 participants