Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/elixir/lib/module/types/descr.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3897,7 +3897,7 @@ defmodule Module.Types.Descr do
defp map_put_static_value(descr, split_keys, type) do
case :maps.take(:dynamic, descr) do
:error ->
if descr_key?(descr, :map) and map_only?(descr) do
if non_empty_map_only?(descr) do
{:ok, map_put_static(descr, split_keys, type)}
else
:badmap
Expand Down
10 changes: 10 additions & 0 deletions lib/elixir/test/elixir/module/types/descr_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3334,6 +3334,16 @@ defmodule Module.Types.DescrTest do

assert map_put(map, atom([:k]), binary()) == {:ok, open_map(k: binary(), x: term())}
end

test "verdict is stable across representations of an empty type" do
# An empty map component that survives syntactically (open_map(c: none())
# is a non-normalized empty, equal to none()) must report :badmap like
# none(), not {:ok, <inhabited>}.
a2 = open_map(c: none())
assert equal?(none(), a2)
assert map_put(none(), atom([:a]), integer()) == :badmap
assert map_put(a2, atom([:a]), integer()) == :badmap
end
end

describe "disjoint" do
Expand Down