Skip to content

Commit 9d61b7e

Browse files
committed
fix: always using AST.equal?/2 to compare variables
1 parent 2fe5a77 commit 9d61b7e

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

lib/refactorex/refactor/variable.ex

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,13 @@ defmodule Refactorex.Refactor.Variable do
4141
zipper
4242
|> Z.topmost_root()
4343
|> Dataflow.analyze()
44-
|> Enum.find(fn
45-
{^variable, _} -> true
46-
{{^name, _, _}, usages} -> Enum.any?(usages, &AST.equal?(&1, variable))
47-
_ -> false
48-
end)
49-
|> then(fn
50-
{declaration, usages} -> [declaration | usages]
51-
_ -> []
44+
|> Stream.map(fn {d, u} -> [d | u] end)
45+
|> Enum.find([], fn
46+
[{^name, _, _} | _] = references ->
47+
Enum.any?(references, &AST.equal?(&1, variable))
48+
49+
_ ->
50+
false
5251
end)
5352
end
5453

0 commit comments

Comments
 (0)