1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

merge revision(s) df14c758fc: [Backport #17181]

Make hash returned by Hash#transform_values not have a default

	This sets an explicit default of nil.  There is probably a better
	approach of removing the default.

	Fixes [Bug #17181]
This commit is contained in:
nagachika 2020-09-29 20:33:06 +09:00
parent c10326d913
commit 665589cbdf
3 changed files with 4 additions and 2 deletions

1
hash.c
View file

@ -3211,6 +3211,7 @@ rb_hash_transform_values(VALUE hash)
RETURN_SIZED_ENUMERATOR(hash, 0, 0, hash_enum_size);
result = hash_copy(hash_alloc(rb_cHash), hash);
SET_DEFAULT(result, Qnil);
if (!RHASH_EMPTY_P(hash)) {
rb_hash_stlike_foreach_with_replace(result, transform_values_foreach_func, transform_values_foreach_replace, result);

View file

@ -1673,6 +1673,7 @@ class TestHash < Test::Unit::TestCase
x.default_proc = proc {|h, k| k}
y = x.transform_values {|v| v ** 2 }
assert_nil(y.default_proc)
assert_nil(y.default)
y = x.transform_values.with_index {|v, i| "#{v}.#{i}" }
assert_equal(%w(1.0 2.1 3.2), y.values_at(:a, :b, :c))

View file

@ -2,11 +2,11 @@
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
#define RUBY_VERSION_TEENY 1
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
#define RUBY_PATCHLEVEL 128
#define RUBY_PATCHLEVEL 129
#define RUBY_RELEASE_YEAR 2020
#define RUBY_RELEASE_MONTH 9
#define RUBY_RELEASE_DAY 20
#define RUBY_RELEASE_DAY 29
#include "ruby/version.h"