diff options
-rw-r--r-- | lib/elixir/lib/kernel.ex | 16 | ||||
-rw-r--r-- | lib/elixir/test/elixir/module_test.exs | 2 |
2 files changed, 17 insertions, 1 deletions
diff --git a/lib/elixir/lib/kernel.ex b/lib/elixir/lib/kernel.ex index 822650e3b..552446bc7 100644 --- a/lib/elixir/lib/kernel.ex +++ b/lib/elixir/lib/kernel.ex @@ -3748,6 +3748,22 @@ defmodule Kernel do Note that, when a dynamic name is used, Elixir won't nest the name under the current module nor automatically set up an alias. + ## Reserved module names + + If you attempt to define a module that already exists, you will get a + warning saying that a module has been redefined. + + There are some modules that Elixir does not currently implement but it + may be implement in the future. Those modules are reserved and defining + them will result in a compilation error: + + defmodule Any do + # code + end + #=> ** (CompileError) iex:1: module Any is reserved and cannot be defined + + Elixir reserves the following module names: `Elixir`, `Any`, `BitString`, + `PID`, and `Reference`. """ defmacro defmodule(alias, do_block) diff --git a/lib/elixir/test/elixir/module_test.exs b/lib/elixir/test/elixir/module_test.exs index e73f079de..56943e32d 100644 --- a/lib/elixir/test/elixir/module_test.exs +++ b/lib/elixir/test/elixir/module_test.exs @@ -261,7 +261,7 @@ defmodule ModuleTest do assert ModuleCreateSample.world() end - test "create with Elixir as a name" do + test "create with a reserved module name" do contents = quote do def world, do: true |