From b516e63fca77a9c3482d6a26f0a552243b9664b2 Mon Sep 17 00:00:00 2001 From: Ian Harris Date: Tue, 12 Nov 2024 14:32:23 -0800 Subject: [PATCH 1/2] clarify `struct!/2` update behavior --- lib/elixir/lib/kernel.ex | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/elixir/lib/kernel.ex b/lib/elixir/lib/kernel.ex index 7a5237a9db0..04e963d3738 100644 --- a/lib/elixir/lib/kernel.ex +++ b/lib/elixir/lib/kernel.ex @@ -2449,8 +2449,9 @@ defmodule Kernel do * when updating a struct, as in `struct!(%SomeStruct{}, key: :value)`, it is equivalent to `%SomeStruct{struct | key: :value}` and therefore this function will check if every given key-value belongs to the struct. - However, updating structs does not enforce keys, as keys are enforced - only when building; + Updating structs does not enforce keys, as keys are enforced + only when building. This is relevant if a struct is created in a way that + avoids key enforcement. """ @spec struct!(module | struct, Enumerable.t()) :: struct From 3877b876f3914a95bab53e6a657a3754b1b77b05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 13 Nov 2024 09:25:32 +0100 Subject: [PATCH 2/2] Update lib/elixir/lib/kernel.ex --- lib/elixir/lib/kernel.ex | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/elixir/lib/kernel.ex b/lib/elixir/lib/kernel.ex index 04e963d3738..f19ad4a0d0c 100644 --- a/lib/elixir/lib/kernel.ex +++ b/lib/elixir/lib/kernel.ex @@ -2449,9 +2449,6 @@ defmodule Kernel do * when updating a struct, as in `struct!(%SomeStruct{}, key: :value)`, it is equivalent to `%SomeStruct{struct | key: :value}` and therefore this function will check if every given key-value belongs to the struct. - Updating structs does not enforce keys, as keys are enforced - only when building. This is relevant if a struct is created in a way that - avoids key enforcement. """ @spec struct!(module | struct, Enumerable.t()) :: struct