Skip to content

Commit 193c15c

Browse files
committed
Restore intersection precision
1 parent 25ffe0e commit 193c15c

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
@@ -3476,17 +3476,19 @@ defmodule Module.Types.Descr do
34763476
if neg_tag == :closed and map_empty?(map_intersection(bdd, neg_bdd)) do
34773477
[{value, bdd} | acc]
34783478
else
3479-
diff_bdd = map_difference(bdd, neg_bdd)
3479+
intersection_value = intersection(value, neg_value)
34803480

3481-
cond do
3482-
value == neg_value or subtype?(value, neg_value) ->
3483-
if map_empty?(diff_bdd), do: acc, else: [{value, diff_bdd} | acc]
3481+
if empty?(intersection_value) do
3482+
[{value, bdd} | acc]
3483+
else
3484+
diff_bdd = map_difference(bdd, neg_bdd)
34843485

3485-
map_empty?(diff_bdd) ->
3486+
if map_empty?(diff_bdd) do
34863487
prepend_pair_unless_empty_diff(value, neg_value, bdd, acc)
3487-
3488-
true ->
3489-
prepend_pair_unless_empty_diff(value, neg_value, bdd, [{value, diff_bdd} | acc])
3488+
else
3489+
acc = [{intersection_value, diff_bdd} | acc]
3490+
prepend_pair_unless_empty_diff(value, neg_value, bdd, acc)
3491+
end
34903492
end
34913493
end
34923494
end)

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

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

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

0 commit comments

Comments
 (0)