$ the-wire · showcase
Elixir compiler warns on unused and duplicated aliases
By RepoJournal · Filed · About Elixir & Phoenix · Composed from the cited sources · methodology
Elixir's compiler now reports unused and duplicated aliases, catching cases where an alias is declared twice or shadowed before it is ever used.
Elixir landed compiler warnings for unused and duplicated aliases, resolving a long-standing request to surface alias declarations that never affect the compiled code [1]. The change covers two distinct cases: aliases that go unused because another alias shadows them, and aliases declared more than once in the same scope [2].
The implementation reworks how the compiler tracks aliases internally, storing `%{alias => [{mod, meta1}, ...]}` instead of the previous `%{{alias, mod} => meta}`, so that each alias can carry per-module metadata [1]. That structure is what lets the compiler mark one entry as used and still flag the duplicate, since only one of the `{mod, meta}` tuples is changed to `{mod, :used}` [1].
For codebases that compile cleanly today, the new warnings can surface as noise on the next compile: shadowed and duplicated aliases that were previously silent now produce warnings under the same unused-alias machinery [1][2]. Because the tracking lives in the compilation environment map, the warnings apply wherever Elixir already reports unused aliases, and no new flags are introduced in the input.
Action items
- → Recompile your Elixir projects and clean up any new unused or duplicated alias warnings elixir-lang/elixir [plan]
References
- [1] Report unused and duplicated aliases ↗ elixir-lang/elixir
- [2] Report unused and duplicated aliases (#15889) ↗ elixir-lang/elixir