Skip to content

mix compile's --warnings-as-errors doesn't work for errors reported by --all-warnings #11628

@Gladear

Description

@Gladear

Environment

  • Elixir & Erlang/OTP versions (elixir --version):
Erlang/OTP 24 [erts-12.2.1] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit]

Elixir 1.13.3 (compiled with Erlang/OTP 24)
  • Operating system:
    macOS Monterney 12.2.1
    or Ubuntu 20.04.3 LTS on Windows 10 x86_64 (WSL 2) / 4.19.128-microsoft-standard

Current behavior

When running mix compile, it looks like warnings reported by --all-warnings aren't considered by --warnings-as-errors.
For example, create a new mix project and add an unused variable anywhere:

$ mix clean
$ mix compile --all-warnings --warnings-as-errors # note that `--all-warning` won't do anything, since we cleaned the project before
Compiling 1 file (.ex)
warning: variable "args" is unused (if the variable is not meant to be used, prefix it with an underscore)
  lib/testmix.ex:15: Testmix.hello/1

Compilation failed due to warnings while using the --warnings-as-errors option
$ # failed as expected
$ mix compile
Compiling 1 file (.ex)
warning: variable "args" is unused (if the variable is not meant to be used, prefix it with an underscore)
  lib/testmix.ex:15: Testmix.hello/1

Generated testmix app
$ mix compile --all-warnings --warnings-as-errors
warning: variable "args" is unused (if the variable is not meant to be used, prefix it with an underscore)
  lib/testmix.ex:15
(compilation went fine)

Expected behavior

Warning reported by the --all-warnings options should be treated the same as others by the --warnings-as-errors option, and therefore that the compilation crashed

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions