From ef14f2b6378931475d58bc84c744cff4eb3f31a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Fri, 31 May 2024 21:23:17 +0200 Subject: [PATCH] WIP --- lib/elixir/lib/module/types/descr.ex | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/elixir/lib/module/types/descr.ex b/lib/elixir/lib/module/types/descr.ex index a9c4fe7a2bb..4a11720b8f4 100644 --- a/lib/elixir/lib/module/types/descr.ex +++ b/lib/elixir/lib/module/types/descr.ex @@ -206,8 +206,10 @@ defmodule Module.Types.Descr do end # For static types, the difference is component-wise. + defp difference_static(left, :term) when not is_optional_static(left), do: none() + defp difference_static(left, right) do - iterator_difference(:maps.next(:maps.iterator(right)), left) + iterator_difference(:maps.next(:maps.iterator(unfold(right))), unfold(left)) end # Returning 0 from the callback is taken as none() for that subtype. @@ -607,7 +609,9 @@ defmodule Module.Types.Descr do defp dynamic_union(:term, other) when not is_optional_static(other), do: :term defp dynamic_union(other, :term) when not is_optional_static(other), do: :term - defp dynamic_union(left, right), do: symmetrical_merge(unfold(left), unfold(right), &union/3) + + defp dynamic_union(left, right), + do: symmetrical_merge(unfold(left), unfold(right), &union/3) defp dynamic_intersection(:term, other) when not is_optional_static(other), do: other defp dynamic_intersection(other, :term) when not is_optional_static(other), do: other @@ -615,8 +619,7 @@ defmodule Module.Types.Descr do defp dynamic_intersection(left, right), do: symmetrical_intersection(unfold(left), unfold(right), &intersection/3) - defp dynamic_difference(left, :term) when not is_optional_static(left), do: %{} - defp dynamic_difference(left, right), do: difference_static(unfold(left), unfold(right)) + defp dynamic_difference(left, right), do: difference_static(left, right) defp dynamic_to_quoted(descr) do cond do