summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-23 17:02:11 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-23 17:02:11 +0000
commit92e97984c60d4f3f43479537e1510039fec9fa28 (patch)
tree6063e43e4d3ee3fc41f6d8984caeda5b7542e50b
parentc758d63138e20d8bcc9f55e36dac1f2757e6eedb (diff)
merge revision(s) 50182,50183: [Backport #11035]
* hash.c (rb_any_hash): Symbols are compared by the identities always. [ruby-core:68767] [Bug #11035] * test/ruby/test_symbol.rb: fix syntax error. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@50620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog9
-rw-r--r--hash.c3
-rw-r--r--test/ruby/test_symbol.rb19
-rw-r--r--version.h2
4 files changed, 32 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 7b11b00db9..a9fb3a4fdb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Sun May 24 02:02:00 2015 Koichi Sasada <ko1@atdot.net>
+
+ * test/ruby/test_symbol.rb: fix syntax error.
+
+Sun May 24 02:02:00 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * hash.c (rb_any_hash): Symbols are compared by the identities
+ always. [ruby-core:68767] [Bug #11035]
+
Sun May 24 02:01:07 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
* hash.c (rb_any_hash): use same hash values with Float#hash so
diff --git a/hash.c b/hash.c
index 3ef0ed458f..fb4c5a5d1b 100644
--- a/hash.c
+++ b/hash.c
@@ -149,6 +149,9 @@ rb_any_hash(VALUE a)
else if (BUILTIN_TYPE(a) == T_STRING) {
hnum = rb_str_hash(a);
}
+ else if (BUILTIN_TYPE(a) == T_SYMBOL) {
+ hnum = rb_objid_hash((st_index_t)a);
+ }
else if (BUILTIN_TYPE(a) == T_FLOAT) {
return rb_dbl_hash(rb_float_value(a));
}
diff --git a/test/ruby/test_symbol.rb b/test/ruby/test_symbol.rb
index 57170fefef..ee29cd544f 100644
--- a/test/ruby/test_symbol.rb
+++ b/test/ruby/test_symbol.rb
@@ -267,4 +267,23 @@ class TestSymbol < Test::Unit::TestCase
200_000.times { |i| i.to_s.to_sym }
end;
end
+
+ def test_hash_redefinition
+ assert_separately([], <<-'end;')
+ bug11035 = '[ruby-core:68767] [Bug #11035]'
+ class Symbol
+ def hash
+ raise
+ end
+ end
+
+ h = {}
+ assert_nothing_raised(RuntimeError, bug11035) {
+ h[:foo] = 1
+ }
+ assert_nothing_raised(RuntimeError, bug11035) {
+ h['bar'.to_sym] = 2
+ }
+ end;
+ end
end
diff --git a/version.h b/version.h
index 832802733a..8e5961959e 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.2.3"
#define RUBY_RELEASE_DATE "2015-05-24"
-#define RUBY_PATCHLEVEL 116
+#define RUBY_PATCHLEVEL 117
#define RUBY_RELEASE_YEAR 2015
#define RUBY_RELEASE_MONTH 5