diff options
Diffstat (limited to 'hash.c')
-rw-r--r-- | hash.c | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -509,7 +509,14 @@ rb_hash_aref(VALUE hash, VALUE key) st_data_t val; if (!RHASH(hash)->ntbl || !st_lookup(RHASH(hash)->ntbl, key, &val)) { - return rb_funcall(hash, id_default, 1, key); + int rb_method_basic_definition_p(VALUE klass, ID id); + if (!FL_TEST(hash, HASH_PROC_DEFAULT) && + rb_method_basic_definition_p(CLASS_OF(hash), id_default)) { + return RHASH_IFNONE(hash); + } + else { + return rb_funcall(hash, id_default, 1, key); + } } return (VALUE)val; } |