2
votes

I have a simple, stand alone module that yields:

elixir impl_bad.ex
** (ArgumentError) argument error

In iex:

=> iex
Erlang/OTP 23 [erts-11.1] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [hipe]

Interactive Elixir (1.9.4) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> c "impl_bad.ex"

== Compilation error in file impl_bad.ex ==
** (ArgumentError) argument error

** (ArgumentError) argument error

The code:

defmodule ImplBad do
  def run_addition_problems(aconfig) do
    do_addition_problems(aconfig)
  end
end

Place this 5 line code in a file by itself.

I know do_addition_problems() does not exist but I would expect an undefined error with a line number.

I extracted this code from a project file where do_addition_problems() does exists.

I would expect a bit more information from the compiler. I had to perform a "binary search" from a module about 1k LOC to pinpoint this problem.

Is this a problem with elixir 1.9.4?

1
Looks like it's indeed the problem with the Elixir version. When I try locally on Elixir 1.9.2, it gives me ArgumentError just like yours. When I try 1.9.4-opt-21, it gives a nice (CompileError) t.ex:3: undefined function do_addition_problems/1. I use asdf tool to switch between the versions of elixir. So it must be something that was fixed in the compiler between 1.9.2 and 1.9.4. - DNNX
Although if I do docker run -it --rm -v "$PWD"/t.ex:/tmp/t.ex elixir:1.9.2-slim elixir /tmp/t.ex, I am getting a good error message, same as elixir:1.9.4-slim. Maybe it's about OTP version rather than Elixir. - DNNX

1 Answers

3
votes

This is an issue of using Erlang/OTP 23 and Elixir 1.9.4 simultaneously.

Elixir 1.9 is older than OTP 23, but fully leverages OTP, so it relies on some warnings/messages coming from compiler during compilation.

That said, downgrading OTP to the version Elixir 1.9 is aware of (21 would be fine, I believe,) or upgrading Elixir to the recent 1.11.1 would fix the issue producing fancy

== Compilation error in file /tmp/test.ex ==
** (CompileError) /tmp/test.ex:3: undefined function do_addition_problems/1
    (elixir 1.11.1) src/elixir_locals.erl:114: anonymous fn/3 in :elixir_locals.ensure_no_undefined_local/3
    (stdlib 3.13.2) erl_eval.erl:680: :erl_eval.do_apply/6