Skip to content

Commit d406a14

Browse files
committed
Remove tag from function nodes
1 parent 9ae86e3 commit d406a14

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ defmodule Module.Types.Descr do
906906
# unary functions with tuple domains to handle special cases like representing functions of a
907907
# specific arity (e.g., (none,none->term) for arity 2).
908908

909-
defp fun_new(inputs, output), do: {{:weak, inputs, output}, :fun_top, :fun_bottom}
909+
defp fun_new(inputs, output), do: {{inputs, output}, :fun_top, :fun_bottom}
910910

911911
@doc """
912912
Creates a function type from a list of inputs and an output where the inputs and/or output may be dynamic.
@@ -1105,8 +1105,8 @@ defmodule Module.Types.Descr do
11051105
result =
11061106
Enum.reduce_while(arrows, none(), fn intersection_of_arrows, acc ->
11071107
Enum.reduce_while(intersection_of_arrows, term(), fn
1108-
{_tag, _dom, _ret}, acc when acc == @none -> {:halt, acc}
1109-
{_tag, _dom, ret}, acc -> {:cont, intersection(acc, ret)}
1108+
{_dom, _ret}, acc when acc == @none -> {:halt, acc}
1109+
{_dom, ret}, acc -> {:cont, intersection(acc, ret)}
11101110
end)
11111111
|> case do
11121112
:term -> {:halt, :term}
@@ -1152,7 +1152,7 @@ defmodule Module.Types.Descr do
11521152
if subtype?(rets_reached, result), do: result, else: union(result, rets_reached)
11531153
end
11541154

1155-
defp aux_apply(result, input, returns_reached, [{_tag, dom, ret} | arrow_intersections]) do
1155+
defp aux_apply(result, input, returns_reached, [{dom, ret} | arrow_intersections]) do
11561156
# Calculate the part of the input not covered by this arrow's domain
11571157
dom_subtract = difference(input, domain_descr(dom))
11581158

@@ -1220,11 +1220,11 @@ defmodule Module.Types.Descr do
12201220
{domain, arrows, arity}
12211221
else
12221222
# Determine arity from first positive function or keep existing
1223-
new_arity = arity || pos_funs |> List.first() |> elem(1) |> length()
1223+
new_arity = arity || pos_funs |> List.first() |> elem(0) |> length()
12241224

12251225
# Calculate domain from all positive functions
12261226
path_domain =
1227-
Enum.reduce(pos_funs, none(), fn {_, args, _}, acc ->
1227+
Enum.reduce(pos_funs, none(), fn {args, _}, acc ->
12281228
union(acc, domain_descr(args))
12291229
end)
12301230

@@ -1281,7 +1281,7 @@ defmodule Module.Types.Descr do
12811281
# e.g. (integer()->atom()) is negated by
12821282
# i) (none()->term()) ii) (none()->atom())
12831283
# ii) (integer()->term()) iv) (integer()->atom())
1284-
Enum.any?(negatives, fn {_tag, neg_arguments, neg_return} ->
1284+
Enum.any?(negatives, fn {neg_arguments, neg_return} ->
12851285
# Filter positives to only those with matching arity, then check if the negative
12861286
# function's domain is a supertype of the positive domain and if the phi function
12871287
# determines emptiness.
@@ -1298,13 +1298,13 @@ defmodule Module.Types.Descr do
12981298
defp fetch_arity_and_domain(positives) do
12991299
positives
13001300
|> Enum.reduce_while({:empty, none()}, fn
1301-
{_tag, args, _}, {:empty, _} ->
1301+
{args, _}, {:empty, _} ->
13021302
{:cont, {length(args), domain_descr(args)}}
13031303

1304-
{_tag, args, _}, {arity, dom} when length(args) == arity ->
1304+
{args, _}, {arity, dom} when length(args) == arity ->
13051305
{:cont, {arity, union(dom, domain_descr(args))}}
13061306

1307-
{_tag, _args, _}, {_arity, _} ->
1307+
{_args, _}, {_arity, _} ->
13081308
{:halt, {:empty, none()}}
13091309
end)
13101310
end
@@ -1329,7 +1329,7 @@ defmodule Module.Types.Descr do
13291329
n = length(arguments)
13301330
# Arity mismatch: if there is one positive function with a different arity,
13311331
# then it cannot be a subtype of the (arguments->type) functions.
1332-
if Enum.any?(positives, fn {_tag, args, _ret} -> length(args) != n end) do
1332+
if Enum.any?(positives, fn {args, _ret} -> length(args) != n end) do
13331333
false
13341334
else
13351335
arguments = Enum.map(arguments, &{false, &1})
@@ -1341,7 +1341,7 @@ defmodule Module.Types.Descr do
13411341
Enum.any?(args, fn {bool, typ} -> bool and empty?(typ) end) or (b and empty?(t))
13421342
end
13431343

1344-
defp phi(args, {b, ret}, [{_tag, arguments, return} | rest_positive]) do
1344+
defp phi(args, {b, ret}, [{arguments, return} | rest_positive]) do
13451345
phi(args, {true, intersection(ret, return)}, rest_positive) and
13461346
Enum.all?(Enum.with_index(arguments), fn {type, index} ->
13471347
List.update_at(args, index, fn {_, arg} -> {true, difference(arg, type)} end)
@@ -1414,7 +1414,7 @@ defmodule Module.Types.Descr do
14141414

14151415
defp fun_intersection_to_quoted(intersection, opts) do
14161416
intersection
1417-
|> Enum.map(fn {_tag, args, ret} ->
1417+
|> Enum.map(fn {args, ret} ->
14181418
{:->, [], [[to_quoted(tuple_descr(:closed, args), opts)], to_quoted(ret, opts)]}
14191419
end)
14201420
|> case do

0 commit comments

Comments
 (0)