Here is a simple module with 2 breakpoints in functions which are calling another functions with names exactly the same as built-in ones: get/1
and put/2
defmodule Test do
def call_put() do
require IEx; IEx.pry
put("k", "v")
end
def call_get() do
require IEx; IEx.pry
get("k")
end
def put(_k, _v)do
IO.puts("Doing put")
end
def get(_k) do
IO.puts("Doing get")
end
end
Executing it in a shell:
iex(1)> Test.call_get
Break reached: Test.call_get/0 (lib/test.ex:7)
5: end
6: def call_get() do
7: require IEx; IEx.pry
8: get("k")
9: end
pry(1)> get("a")
:undefined
pry(2)> Test.get("a")
Doing get
:ok
As it is visible, calling get/1
from debugger results in executing built-in get/1
and put/2
instead of function from my Test
module.
To work it properly I need to namespace my function call. Could anyone explain me this behaviour?