From a00ba65d91c224260d3b455be9e17c8416116e82 Mon Sep 17 00:00:00 2001 From: sabiwara Date: Sun, 12 May 2024 19:35:15 +0900 Subject: [PATCH 1/2] Consistent spec syntax, fixes #13552 --- lib/elixir/lib/regex.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/elixir/lib/regex.ex b/lib/elixir/lib/regex.ex index ddb9fdfe58b..83d88479336 100644 --- a/lib/elixir/lib/regex.ex +++ b/lib/elixir/lib/regex.ex @@ -748,7 +748,7 @@ defmodule Regex do "Abcadc" """ - @spec replace(t, String.t(), String.t() | (... -> String.t()), [{:global, boolean()}]) :: + @spec replace(t, String.t(), String.t() | (... -> String.t()), global: boolean()) :: String.t() def replace(%Regex{} = regex, string, replacement, options \\ []) when is_binary(string) and is_list(options) do From 311330ce191cc0f9f3b6fdee8a9e2a4dbe6dc53f Mon Sep 17 00:00:00 2001 From: sabiwara Date: Sun, 12 May 2024 19:40:24 +0900 Subject: [PATCH 2/2] Explain keyword spec syntax --- lib/elixir/pages/references/typespecs.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/elixir/pages/references/typespecs.md b/lib/elixir/pages/references/typespecs.md index a34bb09f55c..95eb40253f2 100644 --- a/lib/elixir/pages/references/typespecs.md +++ b/lib/elixir/pages/references/typespecs.md @@ -200,6 +200,14 @@ def start_link(opts) do end ``` +The following spec syntaxes are equivalent: + +```elixir +@type options [{:name, String.t} | {:max, pos_integer} | {:min, pos_integer}] + +@type options [name: String.t, max: pos_integer, min: pos_integer] +``` + ### User-defined types The `@type`, `@typep`, and `@opaque` module attributes can be used to define new types: