aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bootstraptest/test_ractor.rb9
-rw-r--r--ractor.rb2
2 files changed, 11 insertions, 0 deletions
diff --git a/bootstraptest/test_ractor.rb b/bootstraptest/test_ractor.rb
index d3ff65ae21..d89bf108c1 100644
--- a/bootstraptest/test_ractor.rb
+++ b/bootstraptest/test_ractor.rb
@@ -163,6 +163,15 @@ assert_equal 30.times.map { 'ok' }.to_s, %q{
}
} unless ENV['RUN_OPTS'] =~ /--jit-min-calls=5/ # This always fails with --jit-wait --jit-min-calls=5
+# Exception for empty select
+assert_match /specify at least one ractor/, %q{
+ begin
+ Ractor.select
+ rescue ArgumentError => e
+ e.message
+ end
+}
+
# Outgoing port of a ractor will be closed when the Ractor is terminated.
assert_equal 'ok', %q{
r = Ractor.new do
diff --git a/ractor.rb b/ractor.rb
index 89e39e5e1c..ca09aee7be 100644
--- a/ractor.rb
+++ b/ractor.rb
@@ -71,6 +71,8 @@ class Ractor
# # and r is :yield
#
def self.select(*ractors, yield_value: yield_unspecified = true, move: false)
+ raise ArgumentError, 'specify at least one ractor or `yield_value`' if yield_unspecified && ractors.empty?
+
__builtin_cstmt! %q{
const VALUE *rs = RARRAY_CONST_PTR_TRANSIENT(ractors);
VALUE rv;