Skip to content

Commit 70e23a4

Browse files
committed
Test inferred types for Map.new/0 and Map.equal?/2
1 parent a9aac52 commit 70e23a4

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

lib/elixir/lib/map.ex

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,11 +1124,7 @@ defmodule Map do
11241124
11251125
"""
11261126
@spec equal?(map, map) :: boolean
1127-
def equal?(map1, map2)
1128-
11291127
def equal?(%{} = map1, %{} = map2), do: map1 === map2
1130-
def equal?(%{} = map1, map2), do: :erlang.error({:badmap, map2}, [map1, map2])
1131-
def equal?(term, other), do: :erlang.error({:badmap, term}, [term, other])
11321128

11331129
@doc false
11341130
@deprecated "Use Kernel.map_size/1 instead"

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ defmodule Module.Types.MapTest do
1111
import Module.Types.Descr
1212
defmacro domain_key(arg) when is_atom(arg), do: [arg]
1313

14+
describe "inferred" do
15+
test "Map.new/0" do
16+
assert typecheck!(Map.new()) == dynamic(empty_map())
17+
end
18+
19+
test "Map.equal?/2" do
20+
assert typecheck!([x, y], {Map.equal?(x, y), x, y}) ==
21+
dynamic(tuple([boolean(), open_map(), open_map()]))
22+
end
23+
end
24+
1425
describe ":maps.take/2" do
1526
test "checking" do
1627
assert typecheck!(:maps.take(:key, %{key: 123})) |> equal?(tuple([integer(), empty_map()]))

0 commit comments

Comments
 (0)