merge revision(s) 62107: [Backport #14420]

force fixable

	* complex.c (nucomp_hash): force hash values fixable.
	  [ruby-core:85224] [Bug #14420]

	* rational.c (nurat_hash): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@62538 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2018-02-22 21:41:46 +00:00
parent c442dd605b
commit 4724dea49e
5 changed files with 12 additions and 6 deletions

View file

@ -1250,7 +1250,7 @@ nucomp_hash(VALUE self)
n = rb_hash(dat->imag); n = rb_hash(dat->imag);
h[1] = NUM2LONG(n); h[1] = NUM2LONG(n);
v = rb_memhash(h, sizeof(h)); v = rb_memhash(h, sizeof(h));
return LONG2FIX(v); return ST2FIX(v);
} }
/* :nodoc: */ /* :nodoc: */

View file

@ -1781,7 +1781,7 @@ nurat_hash(VALUE self)
n = rb_hash(dat->den); n = rb_hash(dat->den);
h[1] = NUM2LONG(n); h[1] = NUM2LONG(n);
v = rb_memhash(h, sizeof(h)); v = rb_memhash(h, sizeof(h));
return LONG2FIX(v); return ST2FIX(v);
} }
static VALUE static VALUE

View file

@ -48,8 +48,12 @@ class Complex_Test < Test::Unit::TestCase
end end
def test_hash def test_hash
assert_kind_of(Integer, Complex(1,2).hash) h = Complex(1,2).hash
assert_kind_of(Integer, Complex(1.0,2.0).hash) assert_kind_of(Integer, h)
assert_nothing_raised {h.to_s}
h = Complex(1.0,2.0).hash
assert_kind_of(Integer, h)
assert_nothing_raised {h.to_s}
h = {} h = {}
h[Complex(0)] = 0 h[Complex(0)] = 0

View file

@ -42,7 +42,9 @@ class Rational_Test < Test::Unit::TestCase
end end
def test_hash def test_hash
assert_kind_of(Integer, Rational(1,2).hash) h = Rational(1,2).hash
assert_kind_of(Integer, h)
assert_nothing_raised {h.to_s}
h = {} h = {}
h[Rational(0)] = 0 h[Rational(0)] = 0

View file

@ -1,6 +1,6 @@
#define RUBY_VERSION "2.5.0" #define RUBY_VERSION "2.5.0"
#define RUBY_RELEASE_DATE "2018-02-23" #define RUBY_RELEASE_DATE "2018-02-23"
#define RUBY_PATCHLEVEL 31 #define RUBY_PATCHLEVEL 32
#define RUBY_RELEASE_YEAR 2018 #define RUBY_RELEASE_YEAR 2018
#define RUBY_RELEASE_MONTH 2 #define RUBY_RELEASE_MONTH 2