6

When I do

mix compile

I get messages like

warning: variable "test_val" is unused
lib/myapp/mymodule.ex:46

I'm just hacking on a side project and I don't care about these warnings for now. Is there a way to turn this off?

2 Answers 2

3

It doesn't look possible, but I could be wrong.

https://groups.google.com/forum/#!topic/elixir-lang-talk/XBnap4u6OkM

https://elixirforum.com/t/is-there-a-way-to-suppress-warnings-about-unused-variables/8637/7

The code that generates the warning (as best I can tell) is elixir_errors:warn and that doesn't have any flags to be able to turn off.

https://github.com/elixir-lang/elixir/search?p=1&q=%3Aelixir_errors.warn&type=&utf8=%E2%9C%93

Nor does it look like there are any code comments you can add to suppress the errors.

Consider it another facet of elixir's very opinionated viewpoint (right along with the "there's only one formatter, and it has no config")

Sign up to request clarification or add additional context in comments.

2 Comments

Your point is valid, but as a side note, the formatter is actually configurable ;-) hexdocs.pm/mix/Mix.Tasks.Format.html#module-formatting-options
And considering that he can shut off the "unused variable" warning with a relatively simple trick, I'd say your answer is somewhat inaccurate.
2

You can stop that particular compiler warning (i. e. test_val is unused) by proceeding the value with _. That is, rename the value to _test_val and you won't get the warning. But if you're warned the variable is unused, maybe you want to double check your code.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.