Skip to content

Commit 360c239

Browse files
committed
Allow early precompiled Elixir to run on Erlang/OTP 28
1 parent 9310ffc commit 360c239

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/elixir/lib/regex.ex

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,8 +561,16 @@ defmodule Regex do
561561
end
562562
end
563563

564-
defp safe_run(%Regex{re_pattern: re_pattern}, string, options) do
565-
:re.run(string, re_pattern, options)
564+
defp safe_run(%Regex{re_pattern: re_pattern} = regex, string, options) do
565+
# TODO: Remove me when Erlang/OTP 28+ is required
566+
# This allows regexes precompiled on Erlang/OTP 27- to work on Erlang/OTP 28+
567+
with true <- :erlang.system_info(:otp_release) >= [?2, ?8],
568+
{:re_pattern, _, _, _, <<_::bitstring>>} <- re_pattern do
569+
%Regex{source: source, opts: compile_opts} = regex
570+
:re.run(string, source, compile_opts ++ options)
571+
else
572+
_ -> :re.run(string, re_pattern, options)
573+
end
566574
end
567575

568576
@doc """

0 commit comments

Comments
 (0)