Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn on unused shadowed aliases #13550

Merged
merged 1 commit into from May 10, 2024
Merged

Conversation

sabiwara
Copy link
Contributor

Close #13549

@@ -220,6 +227,12 @@ defmodule Kernel.LexicalTracker do

def handle_cast({:add_alias, module, meta, warn}, state) do
if warn do
state =
case state do
%{aliases: %{^module => meta}} -> put_in(state.aliases[{:shadowed, module}], meta)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: I reused the aliases map since it's only accessed within this file and it is a rare edge-case anyway, but could also have a shadowed_aliases key in the global state.

@sabiwara sabiwara merged commit d1b3063 into elixir-lang:main May 10, 2024
9 checks passed
@sabiwara sabiwara deleted the unused-alias branch May 10, 2024 13:28
sabiwara added a commit to sabiwara/elixir that referenced this pull request May 17, 2024
sabiwara added a commit that referenced this pull request May 18, 2024
* Revert "Fix false positive with nested shadowed alias (#13564)"

This reverts commit 8dc94db.

* Revert "Warn on unused shadowed aliases (#13550)"

This reverts commit d1b3063.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Shadowing an alias without using it does not warn
2 participants