From c139deda960ade423ff2d5363426bdc58db67928 Mon Sep 17 00:00:00 2001 From: preciz Date: Sat, 5 Sep 2026 19:27:04 +0200 Subject: [PATCH] Correct tuple difference comments Size and content branches may overlap. The disjointness fast path leaves the positive tuple unchanged. Assisted-by: Codex:GPT-6 --- lib/elixir/lib/module/types/descr.ex | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/elixir/lib/module/types/descr.ex b/lib/elixir/lib/module/types/descr.ex index fd9ee0e0118..61c945a826c 100644 --- a/lib/elixir/lib/module/types/descr.ex +++ b/lib/elixir/lib/module/types/descr.ex @@ -4954,14 +4954,15 @@ defmodule Module.Types.Descr do end) end - # Important: this generates DISJOINT tuples. + # Returns tuples whose union is the difference. The size and content + # branches may overlap. defp tuple_eliminate_single_negation(tag, elements, {neg_tag, neg_elements}) do n = length(elements) m = length(neg_elements) - # Scenarios where the difference is guaranteed to be empty: + # Scenarios where the tuples are disjoint, so the positive tuple is unchanged: # 1. When removing larger tuples from a fixed-size positive tuple - # 2. When removing smaller tuples from larger tuples + # 2. When removing smaller fixed-size tuples from larger tuples # 3. When there is no intersection between the elements of the two tuples if (tag == :closed and n < m) or (neg_tag == :closed and n > m) or zip_empty_intersection?(elements, neg_elements) do