Skip to content

Commit b8c1eb7

Browse files
authored
Defer function application computations until needed (#15676)
1 parent 4e61690 commit b8c1eb7

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

lib/elixir/lib/module/types/descr.ex

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,15 +1434,16 @@ defmodule Module.Types.Descr do
14341434
# applying dynamic arrows to upper-bounded arguments in dynamic().
14351435
# - Mixed: union the static result with the dynamic-wrapped dynamic result.
14361436
defp fun_apply_with_strategy(fun_static, fun_dynamic, arguments) do
1437-
args_domain = args_to_domain(arguments)
1438-
static? = fun_dynamic == nil and Enum.all?(arguments, fn arg -> not gradual?(arg) end)
1439-
arity = length(arguments)
1440-
14411437
if Enum.any?(arguments, &empty?/1) do
14421438
{:badarg, arguments, true}
14431439
else
1440+
arity = length(arguments)
1441+
14441442
with {:ok, domain, static_arrows, dynamic_arrows} <-
14451443
fun_normalize_both(fun_static, fun_dynamic, arity) do
1444+
args_domain = args_to_domain(arguments)
1445+
static? = fun_dynamic == nil and Enum.all?(arguments, fn arg -> not gradual?(arg) end)
1446+
14461447
cond do
14471448
# The domain here is the extended gradual domain computed by
14481449
# fun_normalize_both/3. If the argument does not satisfy it, we

0 commit comments

Comments
 (0)