Skip to content

Commit

Permalink
Fix crash when capturing ambiguous import
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszsamson authored and josevalim committed Jun 10, 2024
1 parent 7a4060c commit f3c3d3d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/elixir/src/elixir_dispatch.erl
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ import_function(Meta, Name, Arity, E) ->
false;
{import, Receiver} ->
require_function(Meta, Receiver, Name, Arity, E);
{ambiguous, Ambiguous} ->
{ambiguous, _} = Ambiguous ->
elixir_errors:file_error(Meta, E, ?MODULE, {import, Ambiguous, Name, Arity});
false ->
case elixir_import:special_form(Name, Arity) of
Expand Down
10 changes: 10 additions & 0 deletions lib/elixir/test/elixir/kernel/errors_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,16 @@ defmodule Kernel.ErrorsTest do
end
"""
)

assert_compile_error(
["nofile:3:17", "function exit/1 imported from both :erlang and Kernel, call is ambiguous"],
~c"""
defmodule Kernel.ErrorsTest.FunctionImportConflict do
import :erlang, only: [exit: 1], warn: false
def foo, do: &exit/1
end
"""
)
end

test "ensure valid import :only option" do
Expand Down

0 comments on commit f3c3d3d

Please sign in to comment.