From 7e1e6e91395e5f62679eb454247c3d3edc74debb Mon Sep 17 00:00:00 2001 From: dmitrykleymenov Date: Mon, 7 Apr 2025 09:18:15 +0300 Subject: [PATCH 1/3] Fix to_string doc --- 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 d5054eb6bcb..3d47461a0cd 100644 --- a/lib/elixir/lib/kernel.ex +++ b/lib/elixir/lib/kernel.ex @@ -3392,7 +3392,7 @@ defmodule Kernel do Converts the argument to a string according to the `String.Chars` protocol. - This is the function invoked when there is string interpolation. + This is the macro invoked when there is string interpolation. ## Examples From 09726669f0eb75efaad9cbaeb719216234591893 Mon Sep 17 00:00:00 2001 From: dmitrykleymenov Date: Mon, 7 Apr 2025 09:19:43 +0300 Subject: [PATCH 2/3] Add doctest and description for unquote_splicing in block context --- lib/elixir/lib/kernel/special_forms.ex | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/elixir/lib/kernel/special_forms.ex b/lib/elixir/lib/kernel/special_forms.ex index ae4e9f0a7d6..e914072b3e9 100644 --- a/lib/elixir/lib/kernel/special_forms.ex +++ b/lib/elixir/lib/kernel/special_forms.ex @@ -1372,6 +1372,18 @@ defmodule Kernel.SpecialForms do ...> end {:sum, [], [1, 2, 3, 4, 5]} + Also can be used in block context, outside of function arguments. + Though, it is still required to be wrapped into parentheses. + + iex> requires = for module <- [Integer, Logger] do + ...> quote do + ...> require unquote(module) + ...> end + ...> end + iex> block = quote do: (unquote_splicing(requires)) + iex> Macro.to_string(block) + "require Integer\\nrequire Logger" + """ defmacro unquote(:unquote_splicing)(expr), do: error!([expr]) From b3df2397e45bdb9366f4f52214c1b1ae8c7a873e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Mon, 7 Apr 2025 09:00:35 +0200 Subject: [PATCH 3/3] Update lib/elixir/lib/kernel.ex --- 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 3d47461a0cd..b823b909f42 100644 --- a/lib/elixir/lib/kernel.ex +++ b/lib/elixir/lib/kernel.ex @@ -3392,7 +3392,7 @@ defmodule Kernel do Converts the argument to a string according to the `String.Chars` protocol. - This is the macro invoked when there is string interpolation. + This is invoked when there is string interpolation. ## Examples