[前][次][番号順一覧][スレッド一覧]

ruby-changes:58544

From: Kenichi <ko1@a...>
Date: Sun, 3 Nov 2019 19:03:25 +0900 (JST)
Subject: [ruby-changes:58544] 31110d820c (master): Improve warning message

https://git.ruby-lang.org/ruby.git/commit/?id=31110d820c

From 31110d820cc1258cbc84b46ecc65b254c7d5529a Mon Sep 17 00:00:00 2001
From: Kenichi Kamiya <kachick1@g...>
Date: Sun, 3 Nov 2019 09:24:55 +0900
Subject: Improve warning message

https://github.com/ruby/ruby/pull/2637#discussion_r341812475

diff --git a/re.c b/re.c
index 6b8eda4..34880a8 100644
--- a/re.c
+++ b/re.c
@@ -3324,7 +3324,7 @@ rb_reg_match_m(int argc, VALUE *argv, VALUE re) https://github.com/ruby/ruby/blob/trunk/re.c#L3324
     }
 
     if (NIL_P(str)) {
-        rb_warn("given argument is nil");
+        rb_warn("given argument is nil; this will raise a TypeError in the next release");
     }
     pos = reg_match_pos(re, &str, pos);
     if (pos < 0) {
@@ -3372,7 +3372,7 @@ rb_reg_match_p(VALUE re, VALUE str, long pos) https://github.com/ruby/ruby/blob/trunk/re.c#L3372
     int tmpreg;
 
     if (NIL_P(str)) {
-        rb_warn("given argument is nil");
+        rb_warn("given argument is nil; this will raise a TypeError in the next release");
         return Qfalse;
     }
     str = SYMBOL_P(str) ? rb_sym2str(str) : StringValue(str);
diff --git a/spec/ruby/core/regexp/match_spec.rb b/spec/ruby/core/regexp/match_spec.rb
index 8297be1..e2075d1 100644
--- a/spec/ruby/core/regexp/match_spec.rb
+++ b/spec/ruby/core/regexp/match_spec.rb
@@ -100,7 +100,7 @@ describe "Regexp#match" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/regexp/match_spec.rb#L100
 
   ruby_version_is "2.7"..."3.0" do
     it "warns the deprecation when the given argument is nil" do
-      -> { /foo/.match(nil) }.should complain(/given argument is nil/)
+      -> { /foo/.match(nil) }.should complain(/given argument is nil; this will raise a TypeError in the next release/)
     end
   end
 
@@ -151,7 +151,7 @@ describe "Regexp#match?" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/regexp/match_spec.rb#L151
 
   ruby_version_is "2.7"..."3.0" do
     it "warns the deprecation" do
-      -> { /./.match?(nil) }.should complain(/given argument is nil/)
+      -> { /./.match?(nil) }.should complain(/given argument is nil; this will raise a TypeError in the next release/)
     end
   end
 
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]