summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--re.c2
-rw-r--r--test/ruby/test_regexp.rb5
2 files changed, 6 insertions, 1 deletions
diff --git a/re.c b/re.c
index 1f362247a0..83d4b09aa2 100644
--- a/re.c
+++ b/re.c
@@ -4688,7 +4688,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 4a2ee9dc4c..37375c0e3a 100644
--- a/test/ruby/test_regexp.rb
+++ b/test/ruby/test_regexp.rb
@@ -700,6 +700,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_raise(RegexpError) { Regexp.new(")(") }