From 8ca99ab24d32bc7a0d15c19330c24d2e1a6671a3 Mon Sep 17 00:00:00 2001 From: Jean Klingler Date: Thu, 6 Jun 2024 23:01:53 +0900 Subject: [PATCH] Revert types from #13552 (#13645) --- lib/elixir/lib/regex.ex | 41 ++++++++--------------------------------- 1 file changed, 8 insertions(+), 33 deletions(-) diff --git a/lib/elixir/lib/regex.ex b/lib/elixir/lib/regex.ex index 83d88479336..d53b2010453 100644 --- a/lib/elixir/lib/regex.ex +++ b/lib/elixir/lib/regex.ex @@ -186,27 +186,7 @@ defmodule Regex do defstruct re_pattern: nil, source: "", opts: [], re_version: "" - @type re_option :: - :unicode - | :caseless - | :dotall - | :multiline - | :extended - | :firstline - | :ungreedy - | :anchored - | :dollar_endonly - | :no_auto_capture - | :newline - - @type t :: %__MODULE__{re_pattern: term, source: binary, opts: binary | [re_option()]} - - @type capture_option :: - :all | :first | :all_but_first | :none | :all_names | [binary() | atom()] - @type run_option :: - {:return, :binary | :index} - | {:capture, capture_option()} - | {:offset, non_neg_integer()} + @type t :: %__MODULE__{re_pattern: term, source: binary, opts: binary | [term]} defmodule CompileError do @moduledoc """ @@ -242,7 +222,7 @@ defmodule Regex do {:ok, Regex.compile!("foo", [:caseless])} """ - @spec compile(binary, binary | [re_option()]) :: {:ok, t} | {:error, any} + @spec compile(binary, binary | [term]) :: {:ok, t} | {:error, any} def compile(source, opts \\ "") when is_binary(source) do compile(source, opts, version()) end @@ -270,7 +250,7 @@ defmodule Regex do @doc """ Compiles the regular expression and raises `Regex.CompileError` in case of errors. """ - @spec compile!(binary, binary | [re_option()]) :: t + @spec compile!(binary, binary | [term]) :: t def compile!(source, options \\ "") when is_binary(source) do case compile(source, options) do {:ok, regex} -> regex @@ -377,7 +357,7 @@ defmodule Regex do ["d", ""] """ - @spec run(t, binary, [run_option()]) :: nil | [binary] | [{integer, integer}] + @spec run(t, binary, [term]) :: nil | [binary] | [{integer, integer}] def run(regex, string, options \\ []) def run(%Regex{} = regex, string, options) when is_binary(string) do @@ -412,7 +392,7 @@ defmodule Regex do nil """ - @spec named_captures(t, String.t(), [{:return, :binary | :index}]) :: map | nil + @spec named_captures(t, String.t(), [term]) :: map | nil def named_captures(regex, string, options \\ []) when is_binary(string) do names = names(regex) options = Keyword.put(options, :capture, names) @@ -456,7 +436,7 @@ defmodule Regex do [:caseless] """ - @spec opts(t) :: [re_option()] + @spec opts(t) :: [term] def opts(%Regex{opts: opts}) do opts end @@ -528,7 +508,7 @@ defmodule Regex do [["cd"], ["ce"]] """ - @spec scan(t(), String.t(), [run_option()]) :: [[String.t()]] | [[{integer(), integer()}]] + @spec scan(t(), String.t(), [term()]) :: [[String.t()]] | [[{integer(), integer()}]] def scan(regex, string, options \\ []) def scan(%Regex{} = regex, string, options) when is_binary(string) do @@ -615,12 +595,7 @@ defmodule Regex do ["a", "b", "c"] """ - @spec split(t, String.t(), - parts: pos_integer() | :infinity, - trim: boolean(), - on: capture_option(), - include_captures: boolean() - ) :: [String.t()] + @spec split(t, String.t(), [term]) :: [String.t()] def split(regex, string, options \\ []) def split(%Regex{}, "", opts) do