summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--array.c3
-rw-r--r--test/ruby/test_array.rb17
2 files changed, 20 insertions, 0 deletions
diff --git a/array.c b/array.c
index 64bfcfcf33..6b0396753f 100644
--- a/array.c
+++ b/array.c
@@ -4117,6 +4117,9 @@ rb_ary_product(int argc, VALUE *argv, VALUE ary)
/* put it on the result array */
if(NIL_P(result)) {
rb_yield(subarray);
+ if (RBASIC(t0)->klass) {
+ rb_raise(rb_eRuntimeError, "product reentered");
+ }
}
else {
rb_ary_push(result, subarray);
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb
index 8208b3a2a4..6c84b9238b 100644
--- a/test/ruby/test_array.rb
+++ b/test/ruby/test_array.rb
@@ -780,6 +780,23 @@ class TestArray < Test::Unit::TestCase
assert_match(/reentered/, e.message)
end
+ def test_product_with_callcc
+ respond_to?(:callcc, true) or require 'continuation'
+ n = 1000
+ cont = nil
+ ary = [1,2,3]
+ begin
+ ary.product {
+ callcc {|k| cont = k} unless cont
+ }
+ rescue => e
+ end
+ n -= 1
+ cont.call if 0 < n
+ assert_instance_of(RuntimeError, e)
+ assert_match(/reentered/, e.message)
+ end
+
def test_combination_with_callcc
respond_to?(:callcc, true) or require 'continuation'
n = 1000