I encountered a Internal consistency check failed today in our code base and managed to reproduce it with the following code:
defmodule CompilerBug do
require Logger
def from(order) do
{a, b} =
case order do
"bar" ->
{:bar, 1}
"foo" ->
{:foo, 2}
s ->
Logger.warn("Unexpected order: #{s}")
:error
end
end
end
Pasting this code in iex will result in:
** (CompileError) Elixir.CompilerBug:1: function from/1+65:
Internal consistency check failed - please report this bug.
Instruction: {call_ext,4,{extfunc,'Elixir.Logger','__do_log__',4}}
Error: {allocated,undecided}:
(stdlib 3.17) lists.erl:1342: :lists.foreach/2
(elixir 1.13.4) src/elixir_erl_compiler.erl:12: anonymous fn/2 in :elixir_erl_compiler.spawn/1
Removing any of the three matching arms will result in the module compiling.
Removing Logger.warn will also result in the module compiling.
Replacing Logger.warn with IO.inspect will also result in the module compiling.
iex:
iex
Erlang/OTP 24 [erts-12.2] [source] [64-bit] [smp:10:10] [ds:10:10:10] [async-threads:1]
Interactive Elixir (1.13.4) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)>
Expected behavior
Either compile the module or give a better error message
Elixir and Erlang/OTP versions
elixir --version Erlang/OTP 24 [erts-12.2] [source] [64-bit] [smp:10:10] [ds:10:10:10] [async-threads:1]
Elixir 1.13.4 (compiled with Erlang/OTP 24)
Operating system
Mac Os
Current behavior
I encountered a
Internal consistency check failed
today in our code base and managed to reproduce it with the following code:Pasting this code in iex will result in:
Removing any of the three matching arms will result in the module compiling. Removing
Logger.warn
will also result in the module compiling. ReplacingLogger.warn
withIO.inspect
will also result in the module compiling.iex:
Expected behavior
Either compile the module or give a better error message