elixir
elixir copied to clipboard
Warn about defining implicit alias modules with aliases that are taken
Environment
- Elixir & Erlang/OTP versions (elixir --version): 1.12.1
- Operating system: MacOS BigSur
Current behaviour
For example, initially, you have:
defmodule Post do
defmodule Comment do
end
end
That will generate Post and Post.Comment.
But if later, someone adds an alias to a different module:
defmodule Post do
alias Utils.Comment
defmodule Comment do
end
end
The alias for Post.Comment will not exist anymore.
Expected behaviour
I would expect a failure because Utils.Comment is taken or a warning that Comment is an alias to something else.
The conversation about it started in an Ecto mailing list: https://groups.google.com/g/elixir-ecto/c/rxZT_kzPp2o
What is the expected behavior?
@eksperimental I would expect a warning for nested module definitions when the given module name is an alias defined previously.
Something like:
"warning: Redefining alias Utils.Comment to Post.Comment:5"
Moved to https://github.com/elixir-ecto/ecto/issues/4124