summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rational.c2
-rw-r--r--test/ruby/test_rational.rb7
-rw-r--r--version.h2
3 files changed, 9 insertions, 2 deletions
diff --git a/rational.c b/rational.c
index c606f3c625..dc01425298 100644
--- a/rational.c
+++ b/rational.c
@@ -1875,7 +1875,7 @@ VALUE
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 301890b620..5676b41445 100644
--- a/test/ruby/test_rational.rb
+++ b/test/ruby/test_rational.rb
@@ -598,6 +598,13 @@ class Rational_Test < Test::Unit::TestCase
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 afd5761876..0f507c0a9c 100644
--- a/version.h
+++ b/version.h
@@ -2,7 +2,7 @@
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
#define RUBY_VERSION_TEENY 3
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
-#define RUBY_PATCHLEVEL 152
+#define RUBY_PATCHLEVEL 153
#define RUBY_RELEASE_YEAR 2021
#define RUBY_RELEASE_MONTH 2