- 
        Couldn't load subscription status. 
- Fork 3.5k
Closed
Description
Environment
- Elixir & Erlang/OTP versions (elixir --version): IEx 1.10.4 (compiled with Erlang/OTP 23)
- Operating system: Ubuntu 20.04.2 LTS
Current behavior
Elixir app is compiling despite having an "undefined" warning in it. Take the following code:
defmodule WarningsBug do
  
  def hello do
    Hello.world() ## Hello module does not exist
  end
end
It throws the following warning upon compilation, but the app still compiles.
pokyuser@docker:/workdir/warnings_bug$ mix compile
Compiling 1 file (.ex)
warning: Hello.world/0 is undefined (module Hello is not available or is yet to be defined)
  lib/warnings_bug.ex:4: WarningsBug.hello/0
Generated warnings_bug app
pokyuser@docker:/workdir/warnings_bug$
However, if I try a different warning, such as an unused function warning in the following, the app does not compile, as expected.
defmodule WarningsBug do
  
  defp unused_private_function do
    :ok
  end
end
Produces:
pokyuser@docker:/workdir/warnings_bug$ mix compile
Compiling 1 file (.ex)
warning: function unused_private_function/0 is unused
  lib/warnings_bug.ex:3
Compilation failed due to warnings while using the --warnings-as-errors option
pokyuser@docker:/workdir/warnings_bug$
This is my mix.exs file.
defmodule WarningsBug.MixProject do
  use Mix.Project
  def project do
    [
      app: :warnings_bug,
      version: "0.1.0",
      elixir: "~> 1.10",
      elixirc_options: [warnings_as_errors: true],
      start_permanent: Mix.env() == :prod,
      deps: deps()
    ]
  end
  # Run "mix help compile.app" to learn about applications.
  def application do
    [
      extra_applications: [:logger]
    ]
  end
  # Run "mix help deps" to learn about dependencies.
  defp deps do
    [
      # {:dep_from_hexpm, "~> 0.3.0"},
      # {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"}
    ]
  end
end
It just has only the following file in the lib folder (rather than me creating a separate repo for reproduction)
defmodule WarningsBug do
  
  def hello do
    Hello.world() ## Hello module does not exist
  end
  # defp unused_private_function do
  #   :ok
  # end
end
Expected behavior
Elixir app should fail to compile when the elixirc option to treat warnings_as_errors is set to true.
Metadata
Metadata
Assignees
Labels
No labels