aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--enum.c2
-rw-r--r--test/ruby/test_enum.rb1
2 files changed, 3 insertions, 0 deletions
diff --git a/enum.c b/enum.c
index cd77d9ca7a..c744665949 100644
--- a/enum.c
+++ b/enum.c
@@ -3855,6 +3855,7 @@ enum_sum(int argc, VALUE* argv, VALUE obj)
static VALUE
uniq_func(RB_BLOCK_CALL_FUNC_ARGLIST(i, hash))
{
+ ENUM_WANT_SVALUE();
rb_hash_add_new_element(hash, i, i);
return Qnil;
}
@@ -3862,6 +3863,7 @@ uniq_func(RB_BLOCK_CALL_FUNC_ARGLIST(i, hash))
static VALUE
uniq_iter(RB_BLOCK_CALL_FUNC_ARGLIST(i, hash))
{
+ ENUM_WANT_SVALUE();
rb_hash_add_new_element(hash, rb_yield_values2(argc, argv), i);
return Qnil;
}
diff --git a/test/ruby/test_enum.rb b/test/ruby/test_enum.rb
index 991bda9b3f..c36cb43537 100644
--- a/test/ruby/test_enum.rb
+++ b/test/ruby/test_enum.rb
@@ -977,5 +977,6 @@ class TestEnumerable < Test::Unit::TestCase
assert_equal([[1896, "Athens"], [1900, "Paris"], [1904, "Chicago"], [1908, "Rome"]],
olympics.uniq{|k,v| v})
assert_equal([1, 2, 3, 4, 5, 10], (1..100).uniq{|x| (x**2) % 10 }.first(6))
+ assert_equal([1, [1, 2]], Foo.new.to_enum.uniq)
end
end