elixir icon indicating copy to clipboard operation
elixir copied to clipboard

Warn about defining implicit alias modules with aliases that are taken

Open ulissesalmeida opened this issue 4 years ago • 2 comments

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

ulissesalmeida avatar Jul 21 '21 13:07 ulissesalmeida

What is the expected behavior?

eksperimental avatar Apr 23 '22 02:04 eksperimental

@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"

ulissesalmeida avatar Apr 26 '22 08:04 ulissesalmeida

Moved to https://github.com/elixir-ecto/ecto/issues/4124

josevalim avatar Mar 08 '23 09:03 josevalim