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

Dialyzer message: "Function data/1 has no local return", when default_params is set #46

Closed
ratbag98 opened this issue Aug 27, 2018 · 4 comments

Comments

@ratbag98
Copy link

Using dataloader 1.3 on:

elixir -v
Erlang/OTP 21 [erts-10.0.4] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [hipe]

Elixir 1.6.6 (compiled with OTP 21)

When my data functions look like:

def data(default_params) do
  Dataloader.Ecto.new(Repo, query: &query/2, default_params: default_params)
end

Dialyzer complains with the "Function data/1 has no local return" message, which trickles up to its callers (terminating with the dataloader setup function).

If the code looks like:

def data(default_params) do
  Dataloader.Ecto.new(Repo, query: &query/2)
end

(ie no default_params), then I get no dialyzer warnings (at all, in a 310-file project, how did that happen?). Yay! Of course, I need the default params in order to pass auth information to the queries.

Looking in Dataloader.Ecto.new I see plenty of opportunities for things to go wrong, but I'm not convinced I can fix it before the heat-death of the universe. Any dialyzer gurus fancy taking a look?

Thanks, Rob.

@benwilson512
Copy link
Contributor

This is probably because default_params isn't in the opt typespec, and it should be https://github.com/absinthe-graphql/dataloader/blob/master/lib/dataloader/ecto.ex#L163

I've added it to master, can you try running against master and seeing if that works?

{:dataloader, github: "absinthe-graphql/dataloader"}

@ratbag98
Copy link
Author

That fixed it. Thanks for your customarily insanely rapid response. Seriously, take a break dude.

Side note: I actually tried making that change in my local copy before creating this issue, but I obviously didn't flush some dialyzer cache or did something equally stupid since it didn't do the trick for me.

@benwilson512
Copy link
Contributor

Thanks for pointing it out!

@axelson
Copy link

axelson commented Nov 8, 2018

@ratbag98 You probably needed to pass the --force-check option:

mix dialyzer --force-check

Here's the description of the option: "Force PLT check also if lock file is unchanged. Useful when dealing with local deps."

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

No branches or pull requests

3 participants