diff --git a/struct.c b/struct.c index c0cef33eb7..b85f7c035e 100644 --- a/struct.c +++ b/struct.c @@ -1202,7 +1202,7 @@ rb_struct_hash(VALUE s) h = rb_hash_uint(h, NUM2LONG(n)); } h = rb_hash_end(h); - return INT2FIX(h); + return ST2FIX(h); } static VALUE diff --git a/test/ruby/test_struct.rb b/test/ruby/test_struct.rb index 4748419d6b..db3d767edd 100644 --- a/test/ruby/test_struct.rb +++ b/test/ruby/test_struct.rb @@ -275,6 +275,7 @@ module TestStruct klass = @Struct.new(:a) o = klass.new(1) assert_kind_of(Integer, o.hash) + assert_kind_of(String, o.hash.to_s) end def test_eql