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

ruby-changes:65770

From: usa <ko1@a...>
Date: Mon, 5 Apr 2021 08:40:43 +0900 (JST)
Subject: [ruby-changes:65770] 8890779077 (ruby_2_6): merge revision(s) a55eb9a2af7950d180d9d31ffde2bce66710f44f: [Backport #17572]

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

From 8890779077a556bc56f5f68944988551a9cd78e6 Mon Sep 17 00:00:00 2001
From: usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
Date: Sun, 4 Apr 2021 23:40:30 +0000
Subject: merge revision(s) a55eb9a2af7950d180d9d31ffde2bce66710f44f: [Backport
 #17572]

	Make reciprocal properly of non-integral rational [Bug #17572]

	---
	 rational.c                 | 2 +-
	 test/ruby/test_rational.rb | 7 +++++++
	 2 files changed, 8 insertions(+), 1 deletion(-)

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67926 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
---
 rational.c                 | 2 +-
 test/ruby/test_rational.rb | 7 +++++++
 version.h                  | 2 +-
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/rational.c b/rational.c
index 435a68f..1038059 100644
--- a/rational.c
+++ b/rational.c
@@ -1865,7 +1865,7 @@ VALUE https://github.com/ruby/ruby/blob/trunk/rational.c#L1865
 rb_rational_reciprocal(VALUE x)
 {
     get_dat1(x);
-    return f_rational_new_no_reduce2(CLASS_OF(x), dat->den, dat->num);
+    return nurat_convert(CLASS_OF(x), dat->den, dat->num, FALSE);
 }
 
 /*
diff --git a/test/ruby/test_rational.rb b/test/ruby/test_rational.rb
index a8cdf22..2957e1b 100644
--- a/test/ruby/test_rational.rb
+++ b/test/ruby/test_rational.rb
@@ -598,6 +598,13 @@ class Rational_Test < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rational.rb#L598
     assert_nothing_raised(TypeError, '[Bug #5020] [ruby-dev:44088]') do
       Rational(1,2).coerce(Complex(1,1))
     end
+
+    assert_raise(ZeroDivisionError) do
+      1 / 0r.coerce(0+0i)[0]
+    end
+    assert_raise(ZeroDivisionError) do
+      1 / 0r.coerce(0.0+0i)[0]
+    end
   end
 
   class ObjectX
diff --git a/version.h b/version.h
index 64b9bbc..ca6cbc6 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/version.h#L1
 #define RUBY_VERSION "2.6.7"
 #define RUBY_RELEASE_DATE "2021-04-05"
-#define RUBY_PATCHLEVEL 185
+#define RUBY_PATCHLEVEL 186
 
 #define RUBY_RELEASE_YEAR 2021
 #define RUBY_RELEASE_MONTH 4
-- 
cgit v1.1


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

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