jeremyjh / dialyxir

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

Failed to parse warning (calling function on nil) #410

Open insprac opened 4 years ago

insprac commented 4 years ago

Environment

Current behavior

Attempting to call a function on nil is failing to parse

mix dialyzer output:

Please file a bug in https://github.com/jeremyjh/dialyxir/issues with this message.

Failed to parse warning:
[]

Legacy warning:
:0: Unknown function nil:dataloader_query/2

mix dialyzer --format raw output:

{:warn_unknown, {[], 0}, {:unknown_function, {nil, :dataloader_query, 2}}}
DarkMarmot commented 3 years ago

Just to post what this turned out to be for me:

I had a compile-time configuration that referenced a module and I had set it for :test but not for other environments. So my tests passed but dialyzer (rightly!) complained about me trying to call nil.some_function() in which nil was my missing module reference in the config.

jeremyjh commented 3 years ago

I'm able to reproduce it on Erlang 23.1.1 by inserting this line into any module:

nil.dataloader_query(:any, :args)

I'm not seeing it on Erlang 22, but I also don't see any change in shape in the raw output for this warning. Maybe a bug in yecc??