Getting an error with : warning: variable “MODULE” does not exist and is being expanded to “MODULE()”

When trying to implement the example in GenServer - The Elixir programming language and compiling lib/kv containing bucket.ex and registry.ex I get an error:
warning: variable “MODULE” does not exist and is being expanded to “MODULE()”, please use parentheses to remove the ambiguity or change the variable name
lib/kv/registry.ex:10: KV.Registry.start_link/1

== Compilation error in file lib/kv/registry.ex ==
** (CompileError) lib/kv/registry.ex:10: undefined function MODULE/0 (expected KV.Registry to define such a function or for it to be imported, but none are available)

Line 10 is: GenServer.start_link(MODULE, :ok, opts)

I guess I have missed something in the example but as new to Elixir I don’t eve know where to start looking.

Please use code blocks for code, so we can see it without MARKDOWN formatting being applied.

My guess would be that you’re using _MODULE_ (1 underscore) instead of __MODULE__ (2 underscores).

2 Likes

Thanks! Fast answer and to the point. I did not see that there are two underscores around MODULE.