Suppress specific warnings?

In the specific case of Bitwise.bxor/2's use in a function I have, I find the operator notation more readable than the function notation.

  defp exchange_bits({a, b}, mask) do
    c = (a ^^^ b) &&& mask
    {(a ^^^ c), (b ^^^ c)}

However, the compiler whines about this:

warning: ^^^ is deprecated. It is typically used as xor but it has the wrong precedence, use Bitwise.bxor/2 instead

Obviously, the above code is stable against any upcoming precedence changes… but this warning is blasted out anyway.

Is there any way to suppress this particular warning? I know that, for instance, most Python linters will have directives you can stick in the comments to override their normal behavior within a single line or function without disabling the whole class of warnings. Does Elixir’s built-in linter have anything like that?

It is not linter, it is compilation warning. And no, Elixir do not allow you to disable deprecation warnings, only undefined warnings can be suppressed.

1 Like