@@ -1920,6 +1920,29 @@ defmodule Module.Types.Descr do
1920
1920
1921
1921
def tuple_delete_at ( _ , _ ) , do: :badindex
1922
1922
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
+
1923
1946
@ doc """
1924
1947
Insert an element at the tuple.
1925
1948
@@ -1987,31 +2010,6 @@ defmodule Module.Types.Descr do
1987
2010
end )
1988
2011
end
1989
2012
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
-
2015
2013
# Remove useless negations, which denote tuples of incompatible sizes.
2016
2014
defp tuple_empty_negation? ( tag , n , { neg_tag , neg_elements } ) do
2017
2015
m = length ( neg_elements )
0 commit comments