Skip to content

Commit 86a1c86

Browse files
committed
Restore intersection precision
1 parent f3d8b02 commit 86a1c86

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

lib/elixir/lib/module/types/descr.ex

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3489,17 +3489,19 @@ defmodule Module.Types.Descr do
34893489
if neg_tag == :closed and map_empty?(map_intersection(bdd, neg_bdd)) do
34903490
[{value, bdd} | acc]
34913491
else
3492-
diff_bdd = map_difference(bdd, neg_bdd)
3492+
intersection_value = intersection(value, neg_value)
34933493

3494-
cond do
3495-
value == neg_value or subtype?(value, neg_value) ->
3496-
if map_empty?(diff_bdd), do: acc, else: [{value, diff_bdd} | acc]
3494+
if empty?(intersection_value) do
3495+
[{value, bdd} | acc]
3496+
else
3497+
diff_bdd = map_difference(bdd, neg_bdd)
34973498

3498-
map_empty?(diff_bdd) ->
3499+
if map_empty?(diff_bdd) do
34993500
prepend_pair_unless_empty_diff(value, neg_value, bdd, acc)
3500-
3501-
true ->
3502-
prepend_pair_unless_empty_diff(value, neg_value, bdd, [{value, diff_bdd} | acc])
3501+
else
3502+
acc = [{intersection_value, diff_bdd} | acc]
3503+
prepend_pair_unless_empty_diff(value, neg_value, bdd, acc)
3504+
end
35033505
end
35043506
end
35053507
end)

lib/elixir/test/elixir/module/types/descr_test.exs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2894,9 +2894,7 @@ defmodule Module.Types.DescrTest do
28942894
end
28952895

28962896
test "with projected negative maps and no popped value projection" do
2897-
# map_put/3 passes nil as the popped value accumulator because it only
2898-
# needs the map side. The final negative covers the whole popped map shape
2899-
# but not the key value, so this exercises that nil shortcut directly.
2897+
# map_put/3 passes nil as the popped value accumulator because it only needs the map side.
29002898
map =
29012899
projected_negative_map(100)
29022900
|> difference(open_map(k: atom(), x: term()))

0 commit comments

Comments
 (0)