Skip to content

Delete duplicate keys on :pop in Keyword.get_and_update/3 and get_and_update!/3 - #15604

Merged
josevalim merged 1 commit into
elixir-lang:mainfrom
pnezis:fix-keyword-get-and-update-pop
Jul 14, 2026
Merged

Delete duplicate keys on :pop in Keyword.get_and_update/3 and get_and_update!/3#15604
josevalim merged 1 commit into
elixir-lang:mainfrom
pnezis:fix-keyword-get-and-update-pop

Conversation

@pnezis

@pnezis pnezis commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Both functions document updating "in one pass, deleting duplicate keys", but the :pop branch left any later duplicates in place:

iex> Keyword.get_and_update([a: 1, a: 2], :a, fn _ -> :pop end)
{1, [a: 2]}

I am evaluating claude fable on code review tasks and this was one of the findings

…t_and_update!/3`

Both functions document updating "in one pass, deleting duplicate keys",
but the `:pop` branch left any later duplicates in place:

    Keyword.get_and_update([a: 1, a: 2], :a, fn _ -> :pop end)
    #=> {1, [a: 2]}, expected {1, []}
@josevalim
josevalim merged commit 4c42f94 into elixir-lang:main Jul 14, 2026
15 checks passed
@josevalim

Copy link
Copy Markdown
Member

💚 💙 💜 💛 ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants