warning: variable "params" is unused
lib/supervisor.ex:57
But there is no lib/supervisor.ex in my project. There is lib/master_monitor.ex which on line 57 has an unused params variable. That source file has 3 modules defined in it; the error is in the second module; that module uses Supervisor; and the error is in its init callback. So I can kind of get a feel for how the compiler could go wrong in reporting the source file.
I don’t think it would be trivial to reduce this to a minimal repro case. Is there some other info I could provide? (I could always provide a slightly stripped-down project even if not minimal…)
That’s not an error but a warning. Errors cancel compilation and you have to fix them to get something executable, warnings are just remarks, which you should fix but not necessarily need to [1].
Hava you checked if this warning is really from your project or from one of your dependencies? Does this warning disappear when you prefix that params variable in your file with an underscore (making it _params)?
Also it would be nice to show some code that reproduces that problem to make sure if there is a bug in the compiler or not.
[1] Right now. It’s good style to clean them up though.
Well, I hacked away code, and found that it apparently doesn’t have the kind of complicated dependency I was imagining. Just put this code into lib/monitor_target.ex, and the compiler will warn of unused params in lib/supervisor.ex:
defmodule Monitor.Target do
use Supervisor
def start_link(fubar) do
Supervisor.start_link(__MODULE__, [fubar])
end
def init([_] = params) do
end
end
I have modified your example a bit and removed the pattern match and only left the binding.
And in fact it seems as if you have discovered a regression from 1.3.4 to 1.4.0:
$ cat foo.exs
defmodule Foo do
use Supervisor
def start_link(fubar) do
Supervisor.start_link(__MODULE__, [fubar])
end
def init(params) do
end
end
$ kiex use 1.3.4
Using 1.3.4
$ elixir foo.exs
warning: variable params is unused
foo.exs:8
$ kiex use 1.4.0
Using 1.4.0
$ elixir foo.exs
warning: variable "params" is unused
lib/supervisor.ex:8
As a quick guess, I might think it was introduced by c69fa11, but I am not quite sure.