Skip to content

Commit 0cdaea1

Browse files
authored
Fix definition of term_or_dynamic_optional type (#15498)
Fixes #15497
1 parent a9976cc commit 0cdaea1

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ defmodule Module.Types.Descr do
7676

7777
@not_set %{optional: 1}
7878
@term_or_optional Map.put(@term, :optional, 1)
79-
@term_or_dynamic_optional Map.put(@term, :dynamic, %{optional: 1})
79+
@term_or_dynamic_optional Map.put(@term, :dynamic, @term_or_optional)
8080
@not_atom_or_optional Map.delete(@term_or_optional, :atom)
8181

8282
@empty_intersection [0, :bdd_bot]

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,12 @@ defmodule Module.Types.DescrTest do
10331033
refute subtype?(if_set(term()), term())
10341034
assert subtype?(if_set(term()), if_set(term()))
10351035
refute subtype?(if_set(term()), if_set(dynamic(term())))
1036+
1037+
# Test that union+dynamic optimizations preserves properties
1038+
t = opt_union(term(), dynamic(not_set()))
1039+
assert subtype?(term(), t)
1040+
assert subtype?(dynamic(), t)
1041+
assert subtype?(dynamic(integer()), t)
10361042
end
10371043

10381044
test "list" do

0 commit comments

Comments
 (0)