Should be there some stack trace for calls on nil?

Sometimes I’m calling an attribute on map and there is no actual map in place, just nil instead. In this case there is no helpful trace with line number where error has happened.

I’ve wrote small module to demonstrate the problem:

defmodule NilTrace do
  def call do
    call_nil(nil)
  end

  def call_nil(nil_variable) do
    nil_variable.name
  end
end
Interactive Elixir (1.4.1) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> NilTrace.call
** (UndefinedFunctionError) function nil.name/0 is undefined or private
     nil.name()

Actual file can be pretty big, and without line number I have to guess where error is.

So shouldn’t be there a line number at least, or better, a full trace?

3 Likes