Skip to content

Commit 3163e4c

Browse files
committed
Fix optimizations for closed map checking
1 parent e3cd399 commit 3163e4c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3363,10 +3363,10 @@ defmodule Module.Types.Descr do
33633363
true
33643364

33653365
# The keys is only in the negative map, and the positive map is closed
3366-
# in that case, this field is not_set(), and its difference with the negative map type is empty iff
3367-
# the negative type is optional.
3366+
# in that case, this field is not_set(), and its difference with the
3367+
# negative map type is empty iff the negative type is optional.
33683368
tag == :closed ->
3369-
is_optional_static(neg_type) or map_line_empty?(tag, fields, negs)
3369+
is_optional_static(neg_type)
33703370

33713371
# There may be value in common
33723372
tag == :open ->
@@ -3391,6 +3391,9 @@ defmodule Module.Types.Descr do
33913391
neg_tag == :open ->
33923392
true
33933393

3394+
neg_tag == :closed and not is_optional_static(type) ->
3395+
false
3396+
33943397
true ->
33953398
# an absent key in a open negative map can be ignored
33963399
diff = difference(type, neg_atom_default)

0 commit comments

Comments
 (0)