@@ -5630,31 +5630,33 @@ defmodule Module.Types.Descr do
56305630 end
56315631 end
56325632
5633- defp tuple_insert_static ( descr , _ , _ ) when descr == @ none , do: none ( )
5634-
5635- defp tuple_insert_static ( descr , index , type ) do
5636- Map . update! ( descr , :tuple , fn bdd ->
5637- if tuple_bdd_positive? ( bdd ) do
5638- # A pure disjunction of leaves: the insert distributes over the union, so
5639- # we rewrite each leaf in place (preserving the structure callers assert on).
5640- bdd_map ( bdd , fn bdd_leaf ( tag , elements ) ->
5641- tuple_insert_leaf ( tag , elements , index , type )
5642- end )
5643- else
5644- # The bdd carries negations and/or implicit `:bdd_top` positive paths
5645- # (e.g. from `tuple_difference(open_tuple([]), _) -> bdd_negation`).
5646- # `bdd_map` rewrites only explicit leaves, so it would skip the implicit
5647- # top (losing the insert) and wrongly transform negated leaves. Expand to
5648- # the exact negation-free positive DNF first, then insert into each leaf.
5649- bdd
5650- |> tuple_bdd_to_dnf_no_negations ( )
5651- |> Enum . reduce ( :bdd_bot , fn { tag , elements } , acc ->
5652- tuple_union ( tuple_insert_leaf ( tag , elements , index , type ) , acc )
5653- end )
5654- end
5655- end )
5633+ defp tuple_insert_static ( % { tuple: bdd } = descr , index , type ) do
5634+ % {
5635+ descr
5636+ | tuple:
5637+ if tuple_bdd_positive? ( bdd ) do
5638+ # A pure disjunction of leaves: the insert distributes over the union, so
5639+ # we rewrite each leaf in place (preserving the structure callers assert on).
5640+ bdd_map ( bdd , fn bdd_leaf ( tag , elements ) ->
5641+ tuple_insert_leaf ( tag , elements , index , type )
5642+ end )
5643+ else
5644+ # The bdd carries negations and/or implicit `:bdd_top` positive paths
5645+ # (e.g. from `tuple_difference(open_tuple([]), _) -> bdd_negation`).
5646+ # `bdd_map` rewrites only explicit leaves, so it would skip the implicit
5647+ # top (losing the insert) and wrongly transform negated leaves. Expand to
5648+ # the exact negation-free positive DNF first, then insert into each leaf.
5649+ bdd
5650+ |> tuple_bdd_to_dnf_no_negations ( )
5651+ |> Enum . reduce ( :bdd_bot , fn { tag , elements } , acc ->
5652+ tuple_union ( tuple_insert_leaf ( tag , elements , index , type ) , acc )
5653+ end )
5654+ end
5655+ }
56565656 end
56575657
5658+ defp tuple_insert_static ( _descr , _index , _type ) , do: none ( )
5659+
56585660 # Inserts `type` at `index` into a single tuple literal. If the tuple is open,
56595661 # `List.insert_at` needs the tuple filled with `term()` up to `index` first.
56605662 # Closed tuples of an incorrect size are cancelled before reaching here (the
0 commit comments