From: "nobu (Nobuyoshi Nakada) via ruby-core" <ruby-core@ml.ruby-lang.org>
To: ruby-core@ml.ruby-lang.org
Cc: "nobu (Nobuyoshi Nakada)" <noreply@ruby-lang.org>
Subject: [ruby-core:120377] [Ruby master Bug#20978] Ractor[]/Thread[]/Fiber[] behavior difference
Date: Mon, 23 Dec 2024 11:01:29 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-111154.20241223110128.710@ruby-lang.org> (raw)
In-Reply-To: <redmine.issue-20978.20241222170023.710@ruby-lang.org>
Issue #20978 has been updated by nobu (Nobuyoshi Nakada).
Before commit:d4c720a91bc7bb9ff31810e1720acffb939f7a2f, fiber storage used `rb_check_id` to check arguments.
This function tries to convert a non-Symbol value to a String.
So this bug is a regression, I think.
----------------------------------------
Bug #20978: Ractor[]/Thread[]/Fiber[] behavior difference
https://bugs.ruby-lang.org/issues/20978#change-111154
* Author: zverok (Victor Shepelev)
* Status: Open
* ruby -v: ruby 3.4.0dev (2024-12-22T06:08:19Z master 3808d29e20) +PRISM [x86_64-linux]
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN
----------------------------------------
`Ractor.[]` and `.[]=` support string and symbol keys (treating them by string value, and also accepting anything responding to `#to_str`):
```ruby
Ractor[:value] = 10
Ractor[:value] #=> 10
Ractor['value'] #=> 10
o = Object.new
def o.to_str = 'value'
Ractor[o] #=> 10
Ractor[1]
# in 'Ractor.[]': 1 is not a symbol nor a string (TypeError)
```
But `Fiber.[]` only accept symbols:
```ruby
Fiber[:value] = 10
Fiber['value']
# in 'Fiber.[]': wrong argument type String (expected Symbol) (TypeError)
```
`Thread#[]` and `#[]=` behave like Ractor’s.
(The documentation for Fiber and Thread follows the reality—while Ractor’s current docs don’t specify key type at all—but the discrepancy feels somewhat weird.)
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
next prev parent reply other threads:[~2024-12-23 11:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-22 17:00 [ruby-core:120367] " zverok (Victor Shepelev) via ruby-core
2024-12-23 9:41 ` [ruby-core:120376] " nobu (Nobuyoshi Nakada) via ruby-core
2024-12-23 11:01 ` nobu (Nobuyoshi Nakada) via ruby-core [this message]
2025-01-07 14:28 ` [ruby-core:120523] " Eregon (Benoit Daloze) via ruby-core
2025-01-07 14:44 ` [ruby-core:120525] " zverok (Victor Shepelev) via ruby-core
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-111154.20241223110128.710@ruby-lang.org \
--to=ruby-core@ml.ruby-lang.org \
--cc=noreply@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).