Set#merge: raise if called during iteration

[Bug #21332]
This commit is contained in:
Jean Boussier 2025-05-13 21:39:48 +02:00
parent 1d4822a175
commit 1ee4b43a56
Notes: git 2025-05-13 20:27:55 +00:00
2 changed files with 12 additions and 0 deletions

5
set.c
View file

@ -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;