Skip to content

Commit ad1ffd2

Browse files
committed
Remove unused clause
1 parent b39205b commit ad1ffd2

File tree

2 files changed

+24
-25
lines changed

2 files changed

+24
-25
lines changed

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

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1920,6 +1920,29 @@ defmodule Module.Types.Descr do
19201920

19211921
def tuple_delete_at(_, _), do: :badindex
19221922

1923+
# Takes a static map type and removes an index from it.
1924+
defp tuple_delete_static(%{tuple: dnf}, index) do
1925+
Enum.reduce(dnf, none(), fn
1926+
# Optimization: if there are no negatives, we can directly remove the element
1927+
{tag, elements, []}, acc ->
1928+
union(acc, %{tuple: tuple_new(tag, List.delete_at(elements, index))})
1929+
1930+
{tag, elements, negs}, acc ->
1931+
{fst, snd} = tuple_pop_index(tag, elements, index)
1932+
1933+
union(
1934+
acc,
1935+
case tuple_split_negative(negs, index) do
1936+
:empty -> none()
1937+
negative -> negative |> pair_make_disjoint() |> pair_eliminate_negations_snd(fst, snd)
1938+
end
1939+
)
1940+
end)
1941+
end
1942+
1943+
# If there is no map part to this static type, there is nothing to delete.
1944+
defp tuple_delete_static(_type, _key), do: none()
1945+
19231946
@doc """
19241947
Insert an element at the tuple.
19251948
@@ -1987,31 +2010,6 @@ defmodule Module.Types.Descr do
19872010
end)
19882011
end
19892012

1990-
# Takes a static map type and removes an index from it.
1991-
defp tuple_delete_static(%{tuple: dnf}, index) do
1992-
Enum.reduce(dnf, none(), fn
1993-
# Optimization: if there are no negatives, we can directly remove the element
1994-
{tag, elements, []}, acc ->
1995-
union(acc, %{tuple: tuple_new(tag, List.delete_at(elements, index))})
1996-
1997-
{tag, elements, negs}, acc ->
1998-
{fst, snd} = tuple_pop_index(tag, elements, index)
1999-
2000-
union(
2001-
acc,
2002-
case tuple_split_negative(negs, index) do
2003-
:empty -> none()
2004-
negative -> negative |> pair_make_disjoint() |> pair_eliminate_negations_snd(fst, snd)
2005-
end
2006-
)
2007-
end)
2008-
end
2009-
2010-
defp tuple_delete_static(:term, key), do: open_map([{key, not_set()}])
2011-
2012-
# If there is no map part to this static type, there is nothing to delete.
2013-
defp tuple_delete_static(_type, _key), do: none()
2014-
20152013
# Remove useless negations, which denote tuples of incompatible sizes.
20162014
defp tuple_empty_negation?(tag, n, {neg_tag, neg_elements}) do
20172015
m = length(neg_elements)

lib/elixir/test/elixir/module/types/descr_test.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,7 @@ defmodule Module.Types.DescrTest do
743743
# Succesfully deleting at position `index` in a tuple means that the dynamic
744744
# values that succeed are intersected with tuples of size at least `index`
745745
assert dynamic(tuple()) |> tuple_delete_at(0) == dynamic(tuple())
746+
assert dynamic(term()) |> tuple_delete_at(0) == dynamic(tuple())
746747

747748
assert dynamic(union(tuple(), integer()))
748749
|> tuple_delete_at(1)

0 commit comments

Comments
 (0)