Skip to content

Commit 0883c75

Browse files
author
José Valim
committed
Merge pull request #2164 from liveforeverx/fix_enum
fix matching on every map in Enum.into/2
2 parents 166685c + 5761460 commit 0883c75

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

lib/elixir/lib/enum.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ defmodule Enum do
838838
list ++ to_list(collection)
839839
end
840840

841-
def into(collection, %{}) when is_list(collection) do
841+
def into(collection, %{} = map) when is_list(collection) and (map_size(map) == 0) do
842842
:maps.from_list(collection)
843843
end
844844

lib/elixir/test/elixir/enum_test.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ defmodule EnumTest.List do
187187

188188
test :into do
189189
assert Enum.into([a: 1, b: 2], %{}) == %{a: 1, b: 2}
190+
assert Enum.into([a: 1, b: 2], %{c: 3}) == %{a: 1, b: 2, c: 3}
190191
assert Enum.into(%{a: 1, b: 2}, []) == [a: 1, b: 2]
191192
assert Enum.into([1, 2, 3], "numbers: ", &to_string/1) == "numbers: 123"
192193
assert Enum.into([1, 2, 3], fn

0 commit comments

Comments
 (0)