[前][次][番号順一覧][スレッド一覧]

ruby-changes:63992

From: Marc-Andre <ko1@a...>
Date: Mon, 7 Dec 2020 16:21:32 +0900 (JST)
Subject: [ruby-changes:63992] 53ce71b5af (master): Ractor.select requires an argument or yield_value

https://git.ruby-lang.org/ruby.git/commit/?id=53ce71b5af

From 53ce71b5af09843e1f6dfac7d2f39fa4cf682b12 Mon Sep 17 00:00:00 2001
From: Marc-Andre Lafortune <github@m...>
Date: Sat, 5 Dec 2020 00:04:48 -0500
Subject: Ractor.select requires an argument or yield_value


diff --git a/bootstraptest/test_ractor.rb b/bootstraptest/test_ractor.rb
index d3ff65a..d89bf10 100644
--- a/bootstraptest/test_ractor.rb
+++ b/bootstraptest/test_ractor.rb
@@ -163,6 +163,15 @@ assert_equal 30.times.map { 'ok' }.to_s, %q{ https://github.com/ruby/ruby/blob/trunk/bootstraptest/test_ractor.rb#L163
   }
 } 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 89e39e5..ca09aee 100644
--- a/ractor.rb
+++ b/ractor.rb
@@ -71,6 +71,8 @@ class Ractor https://github.com/ruby/ruby/blob/trunk/ractor.rb#L71
   #   #   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;
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]