parent
1d4822a175
commit
1ee4b43a56
Notes:
git
2025-05-13 20:27:55 +00:00
5
set.c
5
set.c
@ -1139,6 +1139,11 @@ set_i_merge(int argc, VALUE *argv, VALUE set)
|
||||
if (rb_keyword_given_p()) {
|
||||
rb_raise(rb_eArgError, "no keywords accepted");
|
||||
}
|
||||
|
||||
if (set_iterating_p(set)) {
|
||||
rb_raise(rb_eRuntimeError, "cannot add to set during iteration");
|
||||
}
|
||||
|
||||
rb_check_frozen(set);
|
||||
|
||||
int i;
|
||||
|
@ -16,6 +16,13 @@ describe "Set#merge" do
|
||||
-> { Set[1, 2].merge(Object.new) }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "raises RuntimeError when called during iteration" do
|
||||
set = Set[:a, :b]
|
||||
set.each do |_m|
|
||||
-> { set.merge([1, 2]) }.should raise_error(RuntimeError, /iteration/)
|
||||
end
|
||||
end
|
||||
|
||||
ruby_version_is ""..."3.3" do
|
||||
it "accepts only a single argument" do
|
||||
-> { Set[].merge([], []) }.should raise_error(ArgumentError, "wrong number of arguments (given 2, expected 1)")
|
||||
|
Loading…
x
Reference in New Issue
Block a user