Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions lib/elixir/lib/module/types/descr.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1442,12 +1442,10 @@ defmodule Module.Types.Descr do
static? = fun_dynamic == nil and Enum.all?(arguments, fn arg -> not gradual?(arg) end)
arity = length(arguments)

with {:ok, domain, static_arrows, dynamic_arrows} <-
with false <- Enum.any?(arguments, &empty?/1),
{:ok, domain, static_arrows, dynamic_arrows} <-
fun_normalize_both(fun_static, fun_dynamic, arity) do
cond do
Enum.any?(arguments, &empty?/1) ->
{:badarg, domain_to_flat_args(domain, arity)}

# The domain here is the extended gradual domain computed by
# fun_normalize_both/3. If the argument does not satisfy it, we
# check compatibility before rejecting.
Expand Down Expand Up @@ -1498,6 +1496,9 @@ defmodule Module.Types.Descr do
dynamic(fun_apply_static(arguments, dynamic_arrows))
)}
end
else
true -> {:badarg, arguments}
error -> error
end
end

Expand Down
1 change: 1 addition & 0 deletions lib/elixir/test/elixir/module/types/descr_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -1214,6 +1214,7 @@ defmodule Module.Types.DescrTest do
assert fun_apply(dynamic_fun([integer()], atom()), [float()]) == {:ok, dynamic()}
assert fun_apply(dynamic_fun([integer()], atom()), [term()]) == {:ok, dynamic()}
assert fun_apply(dynamic_fun([integer()], none()), [integer()]) == {:ok, dynamic(none())}
assert fun_apply(dynamic(fun([integer()], integer())), [none()]) == {:badarg, [none()]}
assert fun_apply(dynamic_fun([integer()], term()), [integer()]) == {:ok, dynamic()}

# Dynamic return and dynamic args
Expand Down
Loading