diff options
-rw-r--r-- | NEWS.md | 5 | ||||
-rw-r--r-- | common.mk | 3 | ||||
-rw-r--r-- | re.c | 4 | ||||
-rw-r--r-- | test/ruby/test_regexp.rb | 6 |
4 files changed, 17 insertions, 1 deletions
@@ -118,6 +118,10 @@ Note: We're only listing outstanding class updates. * Proc#dup returns an instance of subclass. [[Bug #17545]] * Proc#parameters now accepts lambda keyword. [[Feature #15357]] +* Regexp + * Regexp.new now warns second argument, other than `true`, `false`, + `nil` or Integer. [[Feature #18788]] + * Refinement * Refinement#refined_class has been added. [[Feature #12737]] @@ -263,3 +267,4 @@ The following deprecated APIs are removed. [Bug #18625]: https://bugs.ruby-lang.org/issues/18625 [Bug #18633]: https://bugs.ruby-lang.org/issues/18633 [Bug #18782]: https://bugs.ruby-lang.org/issues/18782 +[Feature #18788]: https://bugs.ruby-lang.org/issues/18788 @@ -12057,12 +12057,15 @@ re.$(OBJEXT): $(hdrdir)/ruby.h re.$(OBJEXT): $(hdrdir)/ruby/ruby.h re.$(OBJEXT): $(top_srcdir)/internal/array.h re.$(OBJEXT): $(top_srcdir)/internal/bits.h +re.$(OBJEXT): $(top_srcdir)/internal/class.h re.$(OBJEXT): $(top_srcdir)/internal/compilers.h re.$(OBJEXT): $(top_srcdir)/internal/gc.h re.$(OBJEXT): $(top_srcdir)/internal/hash.h re.$(OBJEXT): $(top_srcdir)/internal/imemo.h +re.$(OBJEXT): $(top_srcdir)/internal/object.h re.$(OBJEXT): $(top_srcdir)/internal/ractor.h re.$(OBJEXT): $(top_srcdir)/internal/re.h +re.$(OBJEXT): $(top_srcdir)/internal/serial.h re.$(OBJEXT): $(top_srcdir)/internal/static_assert.h re.$(OBJEXT): $(top_srcdir)/internal/string.h re.$(OBJEXT): $(top_srcdir)/internal/time.h @@ -20,6 +20,7 @@ #include "internal/imemo.h" #include "internal/re.h" #include "internal/string.h" +#include "internal/object.h" #include "internal/ractor.h" #include "internal/variable.h" #include "regint.h" @@ -3716,7 +3717,8 @@ rb_reg_initialize_m(int argc, VALUE *argv, VALUE self) else { if (opts != Qundef) { if (FIXNUM_P(opts)) flags = FIX2INT(opts); - else if (RTEST(opts)) flags = ONIG_OPTION_IGNORECASE; + else if (!NIL_P(opts) && rb_bool_expected(opts, "ignorecase", FALSE)) + flags = ONIG_OPTION_IGNORECASE; } if (n_flag != Qundef && !NIL_P(n_flag)) { char *kcode = StringValuePtr(n_flag); diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb index 71d56ad027..5ee6b1b03c 100644 --- a/test/ruby/test_regexp.rb +++ b/test/ruby/test_regexp.rb @@ -628,6 +628,12 @@ class TestRegexp < Test::Unit::TestCase assert_raise(RegexpError) { Regexp.new("((?<v>))\\g<0>") } end + def test_initialize_bool_warning + assert_warning(/expected true or false as ignorecase/) do + Regexp.new("foo", :i) + end + end + def test_match_control_meta_escape assert_equal(0, /\c\xFF/ =~ "\c\xFF") assert_equal(0, /\c\M-\xFF/ =~ "\c\M-\xFF") |