summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNARUSE, Yui <naruse@airemix.jp>2023-03-28 14:25:13 +0900
committerNARUSE, Yui <naruse@airemix.jp>2023-03-28 14:25:13 +0900
commitfb4ffce0dd8cae3b7d0141d3b1ea3f0ab710a45a (patch)
tree04e1e77fbbbe54c7bc43fb278156cde013cac8ee
parentb93e2223300bc54dfa387ffb9fa3d48ecbe670f0 (diff)
downloadruby-fb4ffce0dd8cae3b7d0141d3b1ea3f0ab710a45a.tar.gz
merge revision(s) 680bd9027f8cb7977bbc216609db2f4e3cf199a8: [Backport #19471]
[Bug #19471] `Regexp.compile` should handle keyword arguments As well as `Regexp.new`, it should pass keyword arguments to the `Regexp#initialize` method. --- re.c | 2 +- test/ruby/test_regexp.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-)
-rw-r--r--re.c2
-rw-r--r--test/ruby/test_regexp.rb5
-rw-r--r--version.h2
3 files changed, 7 insertions, 2 deletions
diff --git a/re.c b/re.c
index 65317a4a5f..8bd9117b81 100644
--- a/re.c
+++ b/re.c
@@ -4709,7 +4709,7 @@ Init_Regexp(void)
rb_cRegexp = rb_define_class("Regexp", rb_cObject);
rb_define_alloc_func(rb_cRegexp, rb_reg_s_alloc);
- rb_define_singleton_method(rb_cRegexp, "compile", rb_class_new_instance, -1);
+ rb_define_singleton_method(rb_cRegexp, "compile", rb_class_new_instance_pass_kw, -1);
rb_define_singleton_method(rb_cRegexp, "quote", rb_reg_s_quote, 1);
rb_define_singleton_method(rb_cRegexp, "escape", rb_reg_s_quote, 1);
rb_define_singleton_method(rb_cRegexp, "union", rb_reg_s_union_m, -2);
diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb
index ccdd289dcb..80b652773d 100644
--- a/test/ruby/test_regexp.rb
+++ b/test/ruby/test_regexp.rb
@@ -713,6 +713,11 @@ class TestRegexp < Test::Unit::TestCase
assert_equal(//n, Regexp.new("", Regexp::NOENCODING, timeout: 1))
assert_equal(arg_encoding_none, Regexp.new("", Regexp::NOENCODING).options)
+
+ assert_nil(Regexp.new("").timeout)
+ assert_equal(1.0, Regexp.new("", timeout: 1.0).timeout)
+ assert_nil(Regexp.compile("").timeout)
+ assert_equal(1.0, Regexp.compile("", timeout: 1.0).timeout)
end
assert_deprecated_warning(/3\.3/) do
diff --git a/version.h b/version.h
index e4ac5ea538..34599a6e13 100644
--- a/version.h
+++ b/version.h
@@ -11,7 +11,7 @@
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
#define RUBY_VERSION_TEENY 1
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
-#define RUBY_PATCHLEVEL 47
+#define RUBY_PATCHLEVEL 48
#include "ruby/version.h"
#include "ruby/internal/abi.h"