Skip to content

Commit f3c3d3d

Browse files
lukaszsamsonjosevalim
authored andcommitted
Fix crash when capturing ambiguous import
1 parent 7a4060c commit f3c3d3d

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/elixir/src/elixir_dispatch.erl

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ import_function(Meta, Name, Arity, E) ->
7777
false;
7878
{import, Receiver} ->
7979
require_function(Meta, Receiver, Name, Arity, E);
80-
{ambiguous, Ambiguous} ->
80+
{ambiguous, _} = Ambiguous ->
8181
elixir_errors:file_error(Meta, E, ?MODULE, {import, Ambiguous, Name, Arity});
8282
false ->
8383
case elixir_import:special_form(Name, Arity) of

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

+10
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,16 @@ defmodule Kernel.ErrorsTest do
634634
end
635635
"""
636636
)
637+
638+
assert_compile_error(
639+
["nofile:3:17", "function exit/1 imported from both :erlang and Kernel, call is ambiguous"],
640+
~c"""
641+
defmodule Kernel.ErrorsTest.FunctionImportConflict do
642+
import :erlang, only: [exit: 1], warn: false
643+
def foo, do: &exit/1
644+
end
645+
"""
646+
)
637647
end
638648

639649
test "ensure valid import :only option" do

0 commit comments

Comments
 (0)