From 19e6b3106cb83fd6f968c2969ef92b248859fefd Mon Sep 17 00:00:00 2001 From: sabiwara Date: Thu, 12 Dec 2024 15:00:04 +0900 Subject: [PATCH 1/2] Fix type warning in pop_in/1 --- lib/elixir/lib/kernel.ex | 2 +- lib/elixir/test/elixir/kernel_test.exs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/elixir/lib/kernel.ex b/lib/elixir/lib/kernel.ex index db235db692..93f7404c5b 100644 --- a/lib/elixir/lib/kernel.ex +++ b/lib/elixir/lib/kernel.ex @@ -3308,7 +3308,7 @@ defmodule Kernel do end defp nest_pop_in(:map, h, [{:access, key}]) do - quote do + quote generated: true do case unquote(h) do nil -> {nil, nil} h -> Access.pop(h, unquote(key)) diff --git a/lib/elixir/test/elixir/kernel_test.exs b/lib/elixir/test/elixir/kernel_test.exs index bae0550e3b..fa4b7364a1 100644 --- a/lib/elixir/test/elixir/kernel_test.exs +++ b/lib/elixir/test/elixir/kernel_test.exs @@ -1136,6 +1136,8 @@ defmodule KernelTest do test "pop_in/1" do users = %{"john" => %{age: 27}, "meg" => %{age: 23}} + assert pop_in(users["john"]) == {%{age: 27}, %{"meg" => %{age: 23}}} + assert pop_in(users["john"][:age]) == {27, %{"john" => %{}, "meg" => %{age: 23}}} assert pop_in(users["john"][:name]) == {nil, %{"john" => %{age: 27}, "meg" => %{age: 23}}} assert pop_in(users["bob"][:age]) == {nil, %{"john" => %{age: 27}, "meg" => %{age: 23}}} From e16570202b16b75dc5084c5ae04ca92de1a6f16a Mon Sep 17 00:00:00 2001 From: sabiwara Date: Thu, 12 Dec 2024 17:42:53 +0900 Subject: [PATCH 2/2] Mark the other clause as well --- lib/elixir/lib/kernel.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/elixir/lib/kernel.ex b/lib/elixir/lib/kernel.ex index 93f7404c5b..e31ed3ac46 100644 --- a/lib/elixir/lib/kernel.ex +++ b/lib/elixir/lib/kernel.ex @@ -3329,7 +3329,7 @@ defmodule Kernel do end defp nest_pop_in(_, h, [{:access, key}]) do - quote do + quote generated: true do case unquote(h) do nil -> :pop h -> Access.pop(h, unquote(key))