@@ -1879,17 +1879,14 @@ defmodule Module.Types.Descr do
1879
1879
acc ->
1880
1880
inter = intersection ( list_type1 , list_type2 )
1881
1881
last = intersection ( last_type1 , last_type2 )
1882
+ negs = negs1 ++ negs2
1882
1883
1883
- if empty? ( inter ) or empty? ( last ) do
1884
- acc
1885
- else
1886
- [ { inter , last , negs1 ++ negs2 } | acc ]
1884
+ cond do
1885
+ :lists . member ( { inter , last } , negs ) -> acc
1886
+ empty? ( inter ) or empty? ( last ) -> acc
1887
+ true -> [ { inter , last , negs } | acc ]
1887
1888
end
1888
1889
end
1889
- |> case do
1890
- [ ] -> 0
1891
- dnf -> dnf
1892
- end
1893
1890
end
1894
1891
1895
1892
# Computes the difference between two DNF (Disjunctive Normal Form) list types.
@@ -1902,7 +1899,7 @@ defmodule Module.Types.Descr do
1902
1899
# 3. Base case: adds dnf2 type to negations of dnf1 type
1903
1900
# The result may be larger than the initial dnf1, which is maintained in the accumulator.
1904
1901
defp list_difference ( _ , dnf ) when dnf == @ non_empty_list_top do
1905
- 0
1902
+ [ ]
1906
1903
end
1907
1904
1908
1905
defp list_difference ( dnf1 , dnf2 ) do
@@ -1916,7 +1913,12 @@ defmodule Module.Types.Descr do
1916
1913
Enum . reduce ( negs2 , [ ] , fn { nt , nlast } , nacc ->
1917
1914
t = intersection ( t1 , nt )
1918
1915
last = intersection ( last1 , nlast )
1919
- if empty? ( t ) or empty? ( last ) , do: nacc , else: [ { t , last , negs1 } | nacc ]
1916
+
1917
+ cond do
1918
+ :lists . member ( { t , last } , negs1 ) -> nacc
1919
+ empty? ( t ) or empty? ( last ) -> nacc
1920
+ true -> [ { t , last , negs1 } | nacc ]
1921
+ end
1920
1922
end )
1921
1923
1922
1924
i = intersection ( t1 , t2 )
0 commit comments