Skip to content

Commit 7e08594

Browse files
committed
Add tests for nested struct updates too
1 parent 2096f41 commit 7e08594

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

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

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -872,17 +872,23 @@ defmodule Module.Types.ExprTest do
872872
end
873873

874874
test "updating structs" do
875+
integer_date_type =
876+
dynamic(
877+
closed_map(
878+
__struct__: atom([Date]),
879+
day: integer(),
880+
calendar: term(),
881+
month: term(),
882+
year: term()
883+
)
884+
)
885+
875886
# When we know the type
876887
assert typecheck!([], %Date{Date.new!(1, 1, 1) | day: 31}) ==
877-
dynamic(
878-
closed_map(
879-
__struct__: atom([Date]),
880-
day: integer(),
881-
calendar: term(),
882-
month: term(),
883-
year: term()
884-
)
885-
)
888+
integer_date_type
889+
890+
assert typecheck!([], %Date{%Date{Date.new!(1, 1, 1) | day: 13} | day: 31}) ==
891+
integer_date_type
886892

887893
# When we don't know the type of var
888894
assert typeerror!([x], %Date{x | day: 31}) == ~l"""

0 commit comments

Comments
 (0)