Skip to content

Commit 73dc453

Browse files
author
José Valim
committed
Only raise on conflicts coming from functions
1 parent 2b298ab commit 73dc453

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

lib/elixir/lib/module/locals_tracker.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ defmodule Module.LocalsTracker do
145145
d = :gen_server.call(pid, :digraph, @timeout)
146146

147147
lc { name, arity } inlist all_defined,
148+
:digraph.in_neighbours(d, { :import, name, arity }) != [],
148149
n = :digraph.out_neighbours(d, { :import, name, arity }),
149150
n != [] do
150151
{ n, name, arity }

lib/elixir/test/elixir/kernel/errors_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ defmodule Kernel.ErrorsTest do
242242
"nofile:1: imported Kernel.&&/2 conflicts with local function",
243243
'''
244244
defmodule ErrorsTest do
245-
1 && 2
245+
def other, do: 1 && 2
246246
def _ && _, do: :error
247247
end
248248
'''

lib/elixir/test/elixir/module/locals_tracker_test.exs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,12 @@ defmodule Module.LocalsTrackerTest do
144144
test "find import conflicts", config do
145145
refute { [Module], :conflict, 1 } in D.collect_imports_conflicts(config[:pid], [conflict: 1])
146146

147+
# Calls outside local functions are not triggered
147148
D.add_import(config[:pid], nil, Module, { :conflict, 1 })
149+
refute { [Module], :conflict, 1 } in D.collect_imports_conflicts(config[:pid], [conflict: 1])
150+
151+
D.add_local(config[:pid], { :foo, 2 })
152+
D.add_import(config[:pid], { :foo, 2 }, Module, { :conflict, 1 })
148153
assert { [Module], :conflict, 1 } in D.collect_imports_conflicts(config[:pid], [conflict: 1])
149154
end
150155
end

0 commit comments

Comments
 (0)