1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[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, ...
```
This commit is contained in:
Nobuyoshi Nakada 2022-10-26 19:43:14 +09:00 committed by GitHub
parent a14611cd54
commit 131c31a920
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
Notes: git 2022-10-26 10:43:43 +00:00
Merged: https://github.com/ruby/ruby/pull/6629

Merged-By: nobu <nobu@ruby-lang.org>
3 changed files with 10 additions and 6 deletions

View file

@ -1618,4 +1618,10 @@ assert_equal "ok", %q{
"ok" "ok"
} }
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'] end # if !ENV['GITHUB_WORKFLOW']

View file

@ -1438,12 +1438,6 @@ cancel_single_ractor_mode(void)
} }
ruby_single_main_ractor = NULL; 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 static void

View file

@ -262,6 +262,10 @@ class Ractor
def self.new(*args, name: nil, &block) def self.new(*args, name: nil, &block)
b = block # TODO: builtin bug b = block # TODO: builtin bug
raise ArgumentError, "must be called with a block" unless block 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 = caller_locations(1, 1).first
loc = "#{loc.path}:#{loc.lineno}" loc = "#{loc.path}:#{loc.lineno}"
__builtin_ractor_create(loc, name, args, b) __builtin_ractor_create(loc, name, args, b)