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

ruby-changes:74464

From: nagachika <ko1@a...>
Date: Sun, 13 Nov 2022 11:23:20 +0900 (JST)
Subject: [ruby-changes:74464] f8044a7700 (ruby_3_1): merge revision(s) 131c31a9209c61f84d318aa18b61f468f48b8219: [Backport #19081]

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

From f8044a770009b78d46b583600c9bd6660328303f Mon Sep 17 00:00:00 2001
From: nagachika <nagachika@r...>
Date: Sun, 13 Nov 2022 11:22:53 +0900
Subject: merge revision(s) 131c31a9209c61f84d318aa18b61f468f48b8219: [Backport
 #19081]

	[Bug #19081] Show the caller location in warning for Ractor

	The internal location in ractor.rb is not usefull at all.
	```
	$ ruby -e 'Ractor.new {}'
	<internal:ractor>:267: warning: Ractor is experimental, ...
	```
	---
	 bootstraptest/test_ractor.rb | 6 ++++++
	 ractor.c                     | 6 ------
	 ractor.rb                    | 4 ++++
	 3 files changed, 10 insertions(+), 6 deletions(-)
---
 bootstraptest/test_ractor.rb | 6 ++++++
 ractor.c                     | 6 ------
 ractor.rb                    | 4 ++++
 version.h                    | 2 +-
 4 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/bootstraptest/test_ractor.rb b/bootstraptest/test_ractor.rb
index b29db7ab0e..95c4a39ab4 100644
--- a/bootstraptest/test_ractor.rb
+++ b/bootstraptest/test_ractor.rb
@@ -1579,4 +1579,10 @@ assert_equal "ok", %q{ https://github.com/ruby/ruby/blob/trunk/bootstraptest/test_ractor.rb#L1579
   end
 }
 
+assert_match /\Atest_ractor\.rb:1:\s+warning:\s+Ractor is experimental/, %q{
+  Warning[:experimental] = $VERBOSE = true
+  STDERR.reopen(STDOUT)
+  eval("Ractor.new{}.take", nil, "test_ractor.rb", 1)
+}
+
 end # if !ENV['GITHUB_WORKFLOW']
diff --git a/ractor.c b/ractor.c
index 3c05964e91..4625225dc5 100644
--- a/ractor.c
+++ b/ractor.c
@@ -1432,12 +1432,6 @@ cancel_single_ractor_mode(void) https://github.com/ruby/ruby/blob/trunk/ractor.c#L1432
     }
 
     ruby_single_main_ractor = NULL;
-
-    if (rb_warning_category_enabled_p(RB_WARN_CATEGORY_EXPERIMENTAL)) {
-        rb_category_warn(RB_WARN_CATEGORY_EXPERIMENTAL,
-                         "Ractor is experimental, and the behavior may change in future versions of Ruby! "
-                         "Also there are many implementation issues.");
-    }
 }
 
 static void
diff --git a/ractor.rb b/ractor.rb
index ef36b2937f..bc3d33cae2 100644
--- a/ractor.rb
+++ b/ractor.rb
@@ -262,6 +262,10 @@ class Ractor https://github.com/ruby/ruby/blob/trunk/ractor.rb#L262
   def self.new(*args, name: nil, &block)
     b = block # TODO: builtin bug
     raise ArgumentError, "must be called with a block" unless block
+    if __builtin_cexpr!("RBOOL(ruby_single_main_ractor)")
+      warn("Ractor is experimental, and the behavior may change in future versions of Ruby! " \
+           "Also there are many implementation issues.", uplevel: 0, category: :experimental)
+    end
     loc = caller_locations(1, 1).first
     loc = "#{loc.path}:#{loc.lineno}"
     __builtin_ractor_create(loc, name, args, b)
diff --git a/version.h b/version.h
index 6a2e2abcf9..f226b2832f 100644
--- a/version.h
+++ b/version.h
@@ -11,7 +11,7 @@ https://github.com/ruby/ruby/blob/trunk/version.h#L11
 # define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
 #define RUBY_VERSION_TEENY 3
 #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
-#define RUBY_PATCHLEVEL 180
+#define RUBY_PATCHLEVEL 181
 
 #define RUBY_RELEASE_YEAR 2022
 #define RUBY_RELEASE_MONTH 11
-- 
cgit v1.2.3


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

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