Skip to content

Commit c9ae44e

Browse files
rwstaunerjhawthorn
authored andcommitted
set: fix Set#to_set block behavior and add regression test
1 parent bcddc56 commit c9ae44e

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

set.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ set_i_to_set(VALUE set)
655655
return set;
656656
}
657657

658-
return rb_funcall_passing_block(rb_cSet, id_new, 0, NULL);
658+
return rb_funcall_passing_block(rb_cSet, id_new, 1, &set);
659659
}
660660

661661
/*

test/ruby/test_set.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,8 @@ def test_to_set
978978
assert_equal([-10,-8,-6,-4,-2], set.sort)
979979

980980
assert_same set, set.to_set
981-
assert_not_same set, set.to_set { |o| o }
981+
transformed = set.to_set { |o| o + 1 }
982+
assert_equal([-9,-7,-5,-3,-1], transformed.sort)
982983
end
983984

984985
class MyEnum

0 commit comments

Comments
 (0)